Save workspace changes
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\BlogPost;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<BlogPost>
|
||||
*/
|
||||
final class BlogPostFactory extends Factory
|
||||
{
|
||||
protected $model = BlogPost::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$title = $this->faker->sentence(5);
|
||||
|
||||
return [
|
||||
'slug' => Str::slug($title) . '-' . $this->faker->unique()->numberBetween(1, 99999),
|
||||
'title' => $title,
|
||||
'body' => '<p>' . implode('</p><p>', $this->faker->paragraphs(3)) . '</p>',
|
||||
'excerpt' => $this->faker->sentence(15),
|
||||
'author_id' => null,
|
||||
'featured_image' => null,
|
||||
'meta_title' => null,
|
||||
'meta_description' => null,
|
||||
'is_published' => true,
|
||||
'published_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
|
||||
];
|
||||
}
|
||||
|
||||
public function draft(): static
|
||||
{
|
||||
return $this->state(['is_published' => false, 'published_at' => null]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user