<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
 * Tabela: logs_cabecalhos
 * PK composta: (id, callsign) — definimos primaryKey = 'id' para o Eloquent.
 * Unique: callsign | (callsign, contest)
 */
class LogCabecalho extends Model
{
    protected $table      = 'logs_cabecalhos';
    protected $primaryKey = 'id';
    public    $timestamps = false;   // created_at é gerenciado pelo BD (CURRENT_TIMESTAMP)
    protected $guarded    = [];

    protected $casts = [
        'data_de_nascimento' => 'date',
        'claimed_score'      => 'integer',
        'claimed_calculado'  => 'integer',
        'final_score'        => 'integer',
        'contest_id'         => 'integer',
        'created_at'         => 'datetime',
    ];

    public function qsos(): HasMany
    {
        return $this->hasMany(LogQso::class, 'log_id');
    }
}
