47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\NewsPost;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\NewsPost>
|
|
*/
|
|
class NewsPostFactory extends Factory
|
|
{
|
|
protected $model = NewsPost::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$title = $this->faker->sentence(4);
|
|
|
|
return [
|
|
'title' => [
|
|
'cs' => $title,
|
|
'en' => $title,
|
|
],
|
|
'slug' => Str::slug($title) . '-' . $this->faker->unique()->numberBetween(100, 999),
|
|
'content' => [
|
|
'cs' => $this->faker->paragraph(),
|
|
'en' => $this->faker->paragraph(),
|
|
],
|
|
'excerpt' => [
|
|
'cs' => $this->faker->sentence(),
|
|
'en' => $this->faker->sentence(),
|
|
],
|
|
'is_published' => true,
|
|
'published_at' => now()->subDay(),
|
|
];
|
|
}
|
|
|
|
public function unpublished(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'is_published' => false,
|
|
'published_at' => null,
|
|
]);
|
|
}
|
|
}
|