<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Formation extends Model
{
    use HasFactory;

    protected $fillable = [
        'candidat_id', 'formateur_id', 'type_formation',
        'date_debut', 'date_fin', 'duree_jours', 'statut',
        'note', 'observations',
    ];

    protected $casts = [
        'date_debut' => 'date',
        'date_fin' => 'date',
        'duree_jours' => 'integer',
        'note' => 'decimal:2',
    ];

    // Relations
    public function candidat(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(Candidat::class);
    }

    public function formateur(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(User::class, 'formateur_id');
    }
}
