42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\News>
|
|
*/
|
|
class NewsFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$publishedStatus = fake()->boolean(75);
|
|
$publish_at = Carbon::now()->addMonth();
|
|
$title = fake()->unique()->words(rand(1, 2), true);
|
|
return [
|
|
'seo_title' => fake()->sentence(),
|
|
'seo_description' => fake()->sentence(),
|
|
'title' => $title,
|
|
'subtitle' => fake()->sentence(),
|
|
'content' => fake()->text(),
|
|
'slug' => Str::slug($title),
|
|
'picture_alt' => fake()->sentence(),
|
|
'picture_title' => fake()->sentence(),
|
|
'thumbnail_alt' => fake()->sentence(),
|
|
'thumbnail_title' => fake()->sentence(),
|
|
'highlight' => false,
|
|
'news_category_id' => 1,
|
|
'published' => $publishedStatus,
|
|
'publish_at' => !$publishedStatus ? $publish_at : null,
|
|
'unpublish_at' => !$publishedStatus ? $publish_at->copy()->addDays(rand(10, 20)) : null,
|
|
];
|
|
}
|
|
}
|