|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Database\Factories; |
|
4
|
|
|
|
|
5
|
|
|
use Database\Factories\Traits\ModelChanges; |
|
6
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory; |
|
7
|
|
|
use Illuminate\Support\Collection; |
|
8
|
|
|
use Sfneal\Tracking\Utils\ModelAdapter; |
|
9
|
|
|
|
|
10
|
|
|
class TrackActivityFactory extends Factory |
|
11
|
|
|
{ |
|
12
|
|
|
use ModelChanges; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* TrackActivityFactory constructor. |
|
16
|
|
|
* |
|
17
|
|
|
* @param null $count |
|
|
|
|
|
|
18
|
|
|
* @param Collection|null $states |
|
19
|
|
|
* @param Collection|null $has |
|
20
|
|
|
* @param Collection|null $for |
|
21
|
|
|
* @param Collection|null $afterMaking |
|
22
|
|
|
* @param Collection|null $afterCreating |
|
23
|
|
|
* @param null $connection |
|
|
|
|
|
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct($count = null, |
|
26
|
|
|
?Collection $states = null, |
|
27
|
|
|
?Collection $has = null, |
|
28
|
|
|
?Collection $for = null, |
|
29
|
|
|
?Collection $afterMaking = null, |
|
30
|
|
|
?Collection $afterCreating = null, |
|
31
|
|
|
$connection = null) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->model = ModelAdapter::TrackActivity(); |
|
34
|
|
|
parent::__construct($count, $states, $has, $for, $afterMaking, $afterCreating, $connection); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Define the model's default state. |
|
39
|
|
|
* |
|
40
|
|
|
* @return array |
|
41
|
|
|
*/ |
|
42
|
|
|
public function definition(): array |
|
43
|
|
|
{ |
|
44
|
|
|
return [ |
|
45
|
|
|
'user_id' => $this->faker->randomNumber(3), |
|
46
|
|
|
'route' => $this->route(), |
|
47
|
|
|
'description' => $this->faker->text(), |
|
48
|
|
|
|
|
49
|
|
|
'model_table' => $this->faker->randomElement(['people', 'address']), |
|
50
|
|
|
'model_key' => $this->faker->randomNumber(3), |
|
51
|
|
|
'model_changes' => $this->faker->randomElements($this->modelChanges()), |
|
52
|
|
|
|
|
53
|
|
|
'request_token' => $this->faker->uuid, |
|
54
|
|
|
]; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Retrieve an array of 'route' that can be used as random elements. |
|
59
|
|
|
* |
|
60
|
|
|
* @return string |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function route(): string |
|
63
|
|
|
{ |
|
64
|
|
|
$prefixes = ['projects', 'tasks', 'reports', 'client']; |
|
65
|
|
|
$actions = ['store', 'update', 'delete']; |
|
66
|
|
|
|
|
67
|
|
|
return $this->faker->randomElement($prefixes).'.'.$this->faker->randomElement($actions); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|