<?php

namespace Database\Factories;

use App\Models\PortfolioImage;
use App\Models\PortfolioProject;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<PortfolioProject>
 */
class PortfolioProjectFactory extends Factory
{

    /**
     * Configure the model factory.
     *
     * @return $this
     */
    public function configure()
    {
        return $this->afterCreating(function (PortfolioProject $project) {
            $project->images()->saveMany(PortfolioImage::factory(4)->create([
                'portfolio_project_id'=>$project->id,
            ]));
            $project->skills()->attach([1,4]);
        });
    }
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition()
    {
        return [
            'title' => $this->faker->name,
            'description' => $this->faker->paragraph,
            'portfolioable_id'=>2,
            'portfolioable_type'=>'App\Models\Engineer',
        ];
    }
}
