Passed
Push — master ( 0bc69d...cc8e66 )
by Stephen
56s queued 13s
created

TrackActivityFactory::definition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 8
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
namespace Database\Factories;
4
5
use Database\Factories\Traits\ModelChanges;
6
use Illuminate\Database\Eloquent\Factories\Factory;
7
use Sfneal\Tracking\Models\TrackActivity;
8
9
class TrackActivityFactory extends Factory
10
{
11
    use ModelChanges;
12
13
    /**
14
     * The name of the factory's corresponding model.
15
     *
16
     * @var string
17
     */
18
    protected $model = TrackActivity::class;
19
20
    /**
21
     * Define the model's default state.
22
     *
23
     * @return array
24
     */
25
    public function definition(): array
26
    {
27
        return [
28
            'user_id' => $this->faker->randomNumber(3),
29
            'route' => $this->route(),
30
            'description' => $this->faker->text(),
31
32
            'model_table' => 'people',
33
            'model_key' => $this->faker->randomNumber(3),
34
            'model_changes' => $this->faker->randomElements($this->modelChanges()),
35
36
            'request_token' => $this->faker->uuid,
37
        ];
38
    }
39
40
    /**
41
     * Retrieve an array of 'route' that can be used as random elements.
42
     *
43
     * @return string
44
     */
45
    protected function route(): string
46
    {
47
        $prefixes = ['projects', 'tasks', 'reports', 'client'];
48
        $actions = ['store', 'update',  'delete'];
49
50
        return $this->faker->randomElement($prefixes).'.'.$this->faker->randomElement($actions);
51
    }
52
}
53