<?php

namespace App\Models;

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

class ServiceMacroOverride extends Model
{
    protected $fillable = [
        'service_id',
        'part_type',
    ];

    public function service(): BelongsTo
    {
        return $this->belongsTo(Service::class);
    }

    public function assignments(): HasMany
    {
        return $this->hasMany(ServiceMacroAssignment::class, 'service_id', 'service_id')
            ->where('part_type', $this->part_type);
    }
}
