PostFactory::definition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 0
dl 0
loc 24
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
namespace Database\Factories;
4
5
use App\Models\Post;
6
use Illuminate\Database\Eloquent\Factories\Factory;
7
8
class PostFactory extends Factory
9
{
10
    /**
11
     * The name of the factory's corresponding model.
12
     *
13
     * @var string
14
     */
15
    protected $model = Post::class;
16
17
    /**
18
     * Define the model's default state.
19
     *
20
     * @return array
21
     */
22
    public function definition()
23
    {
24
        return [
25
            'title' => [
26
                'en' => $this->faker->sentence($nbWords = 2, $variableNbWords = true),
27
                'it' => $this->faker->sentence($nbWords = 2, $variableNbWords = true),
28
            ],
29
            'intro_text' => [
30
                'en' => $this->faker->text($maxNbChars = 300),
31
                'it' => $this->faker->text($maxNbChars = 300),
32
            ],
33
            'body' => [
34
                'en' => $this->faker->text($maxNbChars = 1000),
35
                'it' => $this->faker->text($maxNbChars = 1000),
36
            ],
37
            'introimage_alt' => [
38
                'en' => $this->faker->sentence($nbWords = 2, $variableNbWords = true),
39
                'it' => $this->faker->sentence($nbWords = 2, $variableNbWords = true),
40
            ],
41
            //'is_published' => GlobalServices::getRandomWeightedElement(['1'=>85, '0'=>15 ]),
42
            'featured' => $this->faker->numberBetween($min = 0, $max = 1),
43
            'category_id' => $this->faker->numberBetween($min = 1, $max = 3),
44
            'user_id' => 1, //Auth user has a problem here
45
            'introimage' => 'placeholders/placeholder-768x768.png',
46
        ];
47
    }
48
}
49
50
51
52