59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\CmsArticle;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<CmsArticle>
|
|
*/
|
|
class CmsArticleFactory extends Factory
|
|
{
|
|
protected $model = CmsArticle::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$title = fake()->sentence(6);
|
|
|
|
return [
|
|
'slug' => Str::slug($title).'-'.fake()->unique()->numberBetween(100, 999),
|
|
'title' => $title,
|
|
'subtitle' => fake()->sentence(12),
|
|
'image' => 'b2in/magazin-'.fake()->numberBetween(1, 5).'.jpg',
|
|
'category' => fake()->randomElement(['Dubai Investment', 'Rendite & Einrichtung', 'B2B & Partner', 'Einrichtung & Netzwerk']),
|
|
'date_label' => fake()->date('F j, Y'),
|
|
'read_time' => fake()->numberBetween(3, 10).' min read',
|
|
'author' => [
|
|
'name' => fake()->name(),
|
|
'bio' => fake()->sentence(15),
|
|
'avatar' => 'b2in/marcel-scheibe.jpg',
|
|
],
|
|
'content' => ['de' => [
|
|
'intro' => fake()->paragraph(3),
|
|
'sections' => [
|
|
['title' => fake()->sentence(5), 'content' => fake()->paragraph(4)],
|
|
['title' => fake()->sentence(5), 'content' => fake()->paragraph(4)],
|
|
['title' => fake()->sentence(5), 'content' => fake()->paragraph(4)],
|
|
],
|
|
]],
|
|
'is_published' => true,
|
|
'order' => 0,
|
|
];
|
|
}
|
|
|
|
public function published(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_published' => true,
|
|
]);
|
|
}
|
|
|
|
public function unpublished(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_published' => false,
|
|
]);
|
|
}
|
|
}
|