|
2 | 2 |
|
3 | 3 | namespace Tepuilabs\SimpleCrm\Database\Factories;
|
4 | 4 |
|
| 5 | +use Illuminate\Database\Eloquent\Model; |
| 6 | +use Tepuilabs\SimpleCrm\Models\Enums\LeadStatus; |
5 | 7 | use Illuminate\Database\Eloquent\Factories\Factory;
|
6 |
| - |
| 8 | +use Tepuilabs\SimpleCrm\Models\Lead; |
7 | 9 |
|
8 | 10 | class LeadFactory extends Factory
|
9 | 11 | {
|
10 | 12 | /**
|
11 | 13 | * The name of the factory's corresponding model.
|
12 | 14 | *
|
13 |
| - * @var class-string<\Illuminate\Database\Eloquent\Model> |
| 15 | + * @var class-string<Model> |
14 | 16 | */
|
15 |
| - protected $model = \Tepuilabs\SimpleCrm\Models\Lead::class; |
16 |
| - |
17 |
| - const ORGANIC_TYPE = 'Organic'; |
18 |
| - const USER_SUBMITTED_TYPE = 'User Submitted'; |
19 |
| - |
20 |
| - const PROSPECT_STATUS = 'Prospect'; |
21 |
| - const LEAD_STATUS = 'Lead'; |
22 |
| - const CUSTOMER_STATUS = 'Customer'; |
23 |
| - |
| 17 | + protected $model = Lead::class; |
24 | 18 |
|
25 | 19 | /**
|
26 | 20 | * Define the model's default state.
|
27 | 21 | *
|
28 | 22 | * @return array
|
29 | 23 | */
|
30 |
| - public function definition() |
| 24 | + public function definition(): array |
31 | 25 | {
|
32 | 26 | return [
|
33 | 27 | 'name' => $this->faker->name,
|
34 | 28 | 'email' => $this->faker->email,
|
35 |
| - 'type' => $this->faker->randomElement([self::ORGANIC_TYPE, self::USER_SUBMITTED_TYPE]), |
36 |
| - 'status' => $this->faker->randomElement([self::PROSPECT_STATUS, self::LEAD_STATUS, self::CUSTOMER_STATUS]), |
| 29 | + 'type' => $this->faker->randomElement([ |
| 30 | + LeadStatus::ORGANIC_TYPE(), |
| 31 | + LeadStatus::USER_SUBMITTED_TYPE(), |
| 32 | + ]), |
| 33 | + 'status' => $this->faker->randomElement([ |
| 34 | + LeadStatus::PROSPECT_STATUS(), |
| 35 | + LeadStatus::LEAD_STATUS(), |
| 36 | + LeadStatus::CUSTOMER_STATUS(), |
| 37 | + ]), |
37 | 38 | ];
|
38 | 39 | }
|
| 40 | + |
| 41 | + public function typeOrganic() |
| 42 | + { |
| 43 | + return $this->state([ |
| 44 | + 'type' => LeadStatus::ORGANIC_TYPE() |
| 45 | + ]); |
| 46 | + } |
| 47 | + |
| 48 | + public function typeUserSubmitted() |
| 49 | + { |
| 50 | + return $this->state([ |
| 51 | + 'type' => LeadStatus::USER_SUBMITTED_TYPE() |
| 52 | + ]); |
| 53 | + } |
| 54 | + |
| 55 | + public function statusProspect() |
| 56 | + { |
| 57 | + return $this->state([ |
| 58 | + 'status' => LeadStatus::PROSPECT_STATUS() |
| 59 | + ]); |
| 60 | + } |
| 61 | + |
| 62 | + public function statusLead() |
| 63 | + { |
| 64 | + return $this->state([ |
| 65 | + 'status' => LeadStatus::LEAD_STATUS() |
| 66 | + ]); |
| 67 | + } |
| 68 | + |
| 69 | + public function statusCustomer() |
| 70 | + { |
| 71 | + return $this->state([ |
| 72 | + 'status' => LeadStatus::CUSTOMER_STATUS() |
| 73 | + ]); |
| 74 | + } |
39 | 75 | }
|
0 commit comments