<?php namespace Database\Factories; use App\Models\ProjectSector; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; /** * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Project> */ class ProjectFactory extends Factory { /** * Define the model's default state. * * @return array<string, mixed> */ public function definition(): array { $name = $this->faker->words(3, true); return [ 'name' => ucfirst($name), 'slug' => Str::slug($name . '-' . $this->faker->unique()->randomNumber()), 'project_sector_id' => ProjectSector::factory(), 'description' => $this->faker->text(255), // Adjust to column's max length 'city' => $this->faker->city, 'content' => $this->faker->paragraphs(3, true), 'is_published' => $this->faker->boolean(80), 'published_at' => $this->faker->optional()->dateTimeBetween('-1 year', 'now'), 'seo_title' => ucfirst($name) . ' | Example SEO Title', 'is_active' => $this->faker->boolean(70), 'seo_description' => $this->faker->sentence(15), ]; } public function configure(): ProjectFactory { return $this->afterCreating(function ($project) { // Add project cover image $project->addMediaFromUrl('https://picsum.photos/1920/1080') ->toMediaCollection('project-cover'); // Add og-image $project->addMediaFromUrl('https://picsum.photos/1200/630') ->toMediaCollection('project-og-image'); }); } }