40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
class NewsFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition()
|
|
{
|
|
$title = fake()->sentence();
|
|
$publish_at = now()->subDays(rand(1, 30));
|
|
$unpublish_at = $publish_at->copy()->addDays(rand(1, 30));
|
|
$published = now() > $publish_at && now() < $unpublish_at ? true : false;
|
|
|
|
return [
|
|
'seo_title' => fake()->text(70),
|
|
'seo_description' => fake()->text(160),
|
|
'title' => $title,
|
|
'slug' => Str::slug($title),
|
|
'introduction' => \clean(\fake()->randomHtml(6, 7)),
|
|
'content' => \clean(\fake()->randomHtml(6, 7)),
|
|
// phpcs:ignore Generic.Files.LineLength.TooLong
|
|
'linkedin_url' => 'https://fr.linkedin.com/posts/s-n-v_collaborateurs-sant%C3%A9-s%C3%A9curit%C3%A9-activity-7129898234935697408-DV-J',
|
|
'thumbnail_alt' => fake()->sentence(),
|
|
'thumbnail_title' => fake()->sentence(),
|
|
'picture_alt' => fake()->sentence(),
|
|
'picture_title' => fake()->sentence(),
|
|
'published' => $published,
|
|
'publish_at' => $publish_at,
|
|
'unpublish_at' => $unpublish_at,
|
|
];
|
|
}
|
|
}
|