ldc-legaulois/database/factories/ActusFactory.php
2021-09-20 19:13:28 +02:00

35 lines
1.2 KiB
PHP

<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Models\Actu;
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$i = 1;
$factory->define(Actu::class, function (Faker $faker) use (&$i) {
$title = implode(' ', $faker->unique()->words(rand(6, 12)));
$front = ($i++ <= 3 ? true : false);
return [
'title' => $title,
'slug' => \Illuminate\Support\Str::slug($title),
'seo_title' => implode(' ', $faker->words(8)),
'seo_description' => implode(' ', $faker->words(25)),
'header' => $faker->text(300),
'content' => $faker->text(1500),
'picture' => '/assets/images/actus/actu_fake_image.jpg',
'picture_alt' => 'Image de champs',
'front' => $front,
'status' => $front ?: (bool)rand(0, 1)
];
});