<?php

namespace App\Models;

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

class InternshipBooking extends Model
{
    use HasFactory;

    protected $table = 'md_internship_bookings';

    protected $fillable = [
        'instansi_id',
        'leader_id',
        'status_id',
        'expires_at',
    ];

    protected $casts = [
        'expires_at' => 'datetime',
    ];

    public function instansi()
    {
        return $this->belongsTo(Instansi::class, 'instansi_id');
    }

    public function leader()
    {
        return $this->belongsTo(User::class, 'leader_id');
    }

    public function status()
    {
        return $this->belongsTo(MasterData::class, 'status_id');
    }

    public function participants()
    {
        return $this->hasMany(InternshipBookingParticipant::class, 'booking_id');
    }

    public function application()
    {
        return $this->hasOne(InternshipApplication::class, 'booking_id');
    }
}
