<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;

class RoadPatrol extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

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

    public function cmmsMachines(): MorphToMany
    {
        return $this->morphToMany(CMMSMachine::class,
            'machinable',
            'machinables',
            'machinable_id',
            'machine_id'
        );
    }

    public function rahdaran(): MorphToMany
    {
        return $this->morphToMany(Rahdaran::class,
            'rahdarable',
            'rahdarables',
            'rahdarable_id',
            'rahdar_id',
        );
    }
}
