Using Faker Slug in Laravel
{use Illuminate\Support\Str; use App\Models\Post; class PostFactory extends Factory { protected $model = Post::class; public function definition(): array { return [ 'title' => $title = $this->faker->sentence(), 'slug' => Str::slug($title), 'content' => $this->faker->paragraph(), 'published_at' => null, ]; }