35 lines
1.1 KiB
PHP
35 lines
1.1 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()
|
|
{
|
|
$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;
|
|
|
|
$title = fake()->unique()->slug(3);
|
|
return [
|
|
'title' => Str::of($title)->replace('-', ' ')->title(),
|
|
'slug' => Str::slug($title),
|
|
'seo_title' => fake()->sentence(),
|
|
'seo_description' => fake()->sentence(),
|
|
'picture_alt' => fake()->sentence(),
|
|
'picture_title' => fake()->sentence(),
|
|
'text' => \clean(\fake()->randomHtml(1, 1)),
|
|
'published' => $published,
|
|
'publish_at' => $publish_at,
|
|
'unpublish_at' => $unpublish_at,
|
|
];
|
|
}
|
|
}
|