ldc-loue/database/factories/NewsFactory.php

39 lines
1 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Database\Factories;
use App\Enums\PublishedStatus;
use App\Models\News;
use Illuminate\Database\Eloquent\Factories\Factory;
class NewsFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = News::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$title = $this->faker->unique()->words(rand(6, 12), true);
return [
'title' => $title,
'slug' => \Illuminate\Support\Str::slug($title),
'seo_title' => $this->faker->words(8, true),
'seo_description' => $this->faker->words(25, true),
'content' => $this->faker->text(1500),
'picture' => '/assets/images/actus/actu_fake_image_300_300.jpg',
'picture_title' => 'Image de champs',
'picture_alt' => 'Image de champs',
'published' => collect(PublishedStatus::toArray())->random()
];
}
}