<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;

class ContractsSeeder extends Seeder
{
    public function run()
    {
        $clients = DB::table('clients')->pluck('id')->toArray();
        $contracts = [];
        for ($i = 1; $i <= 10; $i++) {
            $contracts[] = [
                'name' => 'Contract ' . $i,
                'client_id' => $clients[array_rand($clients)],
                'description' => 'Description for contract ' . $i,
                'start_date' => now()->subDays(rand(0, 365)),
                'end_date' => now()->addDays(rand(30, 365)),
                'value' => rand(1000, 10000),
                'status' => 'active',
                'created_at' => now(),
                'updated_at' => now(),
            ];
        }
        DB::table('contracts')->insert($contracts);
    }
} 