<?php

namespace Database\Seeders;

use App\Models\Company;
use App\Models\Driver;
use App\Models\Truck;
use Illuminate\Database\Seeder;

class DriverSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $company = Company::first();
        $truck1 = Truck::first();

        if (! $company) {
            return;
        }

        Driver::updateOrCreate(
            ['email' => 'driver1@truetrucker.com'],
            [
                'company_id' => $company->id,
                'name' => 'Driver One',
                'phone' => '5550001111',
                'truck_id' => $truck1?->id,
                'is_active' => true,
                'salary_per_mile' => 0.55,
                'salary_percent' => 26.00,
            ]
        );

        Driver::updateOrCreate(
            ['email' => 'driver2@truetrucker.com'],
            [
                'company_id' => $company->id,
                'name' => 'Driver Two',
                'phone' => '5550002222',
                'truck_id' => null,
                'is_active' => true,
                'salary_per_mile' => 0.58,
                'salary_percent' => 27.50,
            ]
        );
    }
}
