<?php

namespace Modules\MedWard\Entities;

use Illuminate\Database\Eloquent\Model;

/**
 * A bed-history row for an admission (SIFA P6-T2 bed_assignment). The open row
 * (released_at NULL) is the current placement; AdmissionService rolls it on
 * transfer / discharge.
 */
class MedwardBedAssignment extends Model
{
    protected $table = 'medward_bed_assignments';

    protected $guarded = ['id'];

    protected $casts = [
        'assigned_at' => 'datetime',
        'released_at' => 'datetime',
    ];

    public function admission()
    {
        return $this->belongsTo(MedwardAdmission::class, 'admission_id');
    }

    public function bed()
    {
        return $this->belongsTo(MedwardBed::class, 'bed_id');
    }
}
