<?php

namespace App\Models;

use App\Models\BaseModel;

class CompetitionClassWinner extends BaseModel
{
    protected $table = 'competition_class_winners';

    // ✅ CI: useTimestamps = true (created_at/updated_at)
    public $timestamps = true;

    protected $fillable = [
        'competition_id',
        'class_section_id',
        'winners_override',
        'created_at',
        'updated_at',
        'question_count',
        'prize_1',
        'prize_2',
        'prize_3',
        'prize_4',
        'prize_5',
        'prize_6',
    ];

    protected $casts = [
        'competition_id'    => 'integer',
        'class_section_id'  => 'integer',
        'question_count'    => 'integer',
        // If winners_override is JSON in DB, cast to array:
        'winners_override'  => 'array',
    ];

    /* Optional relationships */
    public function competition()
    {
        return $this->belongsTo(Competition::class, 'competition_id');
    }

    public function classSection()
    {
        return $this->belongsTo(ClassSection::class, 'class_section_id');
    }
}