<?php

namespace Database\Factories;

use App\Models\Certificate;
use App\Models\Education;
use App\Models\Engineer;
use App\Models\Experience;
use App\Models\Firm;
use App\Models\License;
use App\Models\PortfolioProject;
use App\Models\User;
use App\Models\Wallet;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<Firm>
 */
class FirmFactory extends Factory
{

    /**
     * Configure the model factory.
     *
     * @return $this
     */
    public function configure()
    {
        return $this->afterCreating(function (Firm $firm) {
            $firm->skills()->attach([1,3]);
            $firm->addLocation([
                'long'=> 31.233334,
                'lat'=> 30.033333,
                'address' => 'Cairo, Egypt',
            ]);
            $firm->addPhone([
                'number'=>'155555555',
                'code'=>'EG',
            ]);

            $firm->categories()->attach([24,25,27]);

            $firm->addSocials([
                'facebook'=>$this->faker->url,
                'instagram'=>$this->faker->url,
            ]);
            $firm->addCurrency(1);
            $firm->licenses()->save(License::factory()->create([
                'firm_id'=>$firm->id,
            ]));
            $firm->portfolioProjects()->save(PortfolioProject::factory()->create([
                'portfolioable_id'=>$firm->id,
                'portfolioable_type'=>'App\Models\Firm',
            ]));
            $firm->wallet()->save(Wallet::factory()->create());
        });
    }
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition()
    {
        return [
            'name' => $this->faker->name(),
            'email' => $this->faker->email(),
            'website' => $this->faker->url(),
            'about' => $this->faker->paragraph(),
            'tag_line' => $this->faker->sentence(),
            'firm_type_id' => $this->faker->numberBetween(1, 3),
            'firm_size_id' => $this->faker->numberBetween(1, 3),
            'category_id' => 2,
            'commercial_registration_number' => $this->faker->unique()->randomNumber(),
            'commercial_registration_path' => $this->faker->imageUrl(),
            'company_profile_path' => $this->faker->imageUrl(),
            'owner_id_path' => $this->faker->imageUrl(),
            'contact_person_id_path' => $this->faker->imageUrl(),
            'user_id' => User::factory(),
        ];
    }
}
