<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Models\Programme;

class ProgrammeSeeder extends Seeder
{
    public function run(): void
    {
        $programmes = [
            ['code' => 'CACPT', 'description' => 'Certificate in Professional Cookery', 'total_credits' => 156, 'duration' => 0.5],
            ['code' => 'CACFT', 'description' => 'Certificate in Professional Cookery', 'total_credits' => 168, 'duration' => 1],
            ['code' => 'CADF',  'description' => 'Diploma in Professional Cookery', 'total_credits' => 168, 'duration' => 0.5],
            ['code' => 'CADPT', 'description' => 'Diploma in Professional Cookery', 'total_credits' => 168, 'duration' => 0.5],
        ];

        foreach ($programmes as $data) {
            if (!DB::table('programmes')->where('code', $data['code'])->exists()) {
                DB::table('programmes')->insert([
                    'code' => $data['code'],
                    'description' => $data['description'],
                    'total_credits' => $data['total_credits'],
                    'duration' => $data['duration'],
                    'status' => 'ongoing',
                    'created_at' => now(),
                    'updated_at' => now(),
                ]);
            }
        }
    }
}
