Initial commit
This commit is contained in:
46
database/factories/NewsPostFactory.php
Normal file
46
database/factories/NewsPostFactory.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user