<?php

namespace App\Models;

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

class RequestLogDailyMonitoring extends Model
{
    use HasFactory;

    public function requestLog()
    {
        return $this->belongsTo(RequestLog::class);
    }

    public function requestLogMedicalPlans()
    {
        return $this->hasMany(RequestLogMedicalPlan::class);
    }

    /* -------------------------------------------------------------------------- */

    protected function code(): Attribute
    {
        return Attribute::make(
            get: fn ($value, $attributes) => 'RE-' . str_pad($attributes['id'], 3, '0', STR_PAD_LEFT),
        );
    }
}
