<?php

namespace App\Models;

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

class Approval extends Model
{
    protected $fillable = ['model_type', 'model_id', 'required_approvals', 'status'];

    protected $with = ['items.user'];

    public function items(): HasMany
    {
        return $this->hasMany(ApprovalItem::class);
    }

    public function approvable()
    {
        return $this->morphTo(__FUNCTION__, 'model_type', 'model_id');
    }
}
