ldc-legaulois/database/factories/ActuFactory.php
2022-02-10 16:14:58 +01:00

41 lines
1.1 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Actu;
use Illuminate\Database\Eloquent\Factories\Factory;
class ActuFactory extends Factory
{
protected static $i = 1;
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Actu::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$title = implode(' ', $this->faker->unique()->words(rand(6, 12)));
$front = (static::$i++ <= 3 ? true : false);
return [
'title' => $title,
'slug' => \Illuminate\Support\Str::slug($title),
'seo_title' => implode(' ', $this->faker->words(8)),
'seo_description' => implode(' ', $this->faker->words(25)),
'header' => $this->faker->text(300),
'content' => $this->faker->text(1500),
'picture' => '/assets/images/actus/actu_fake_image.jpg',
'picture_alt' => 'Image de champs',
'front' => $front,
'status' => $front ?: (bool)rand(0, 1)
];
}
}