<?php

namespace Modules\VetAdmission\Entities;

use Illuminate\Database\Eloquent\Model;

class VaProtocol extends Model
{
    protected $table = 'va_protocols';
    protected $guarded = ['id'];

    public function items()
    {
        return $this->hasMany(VaProtocolItem::class, 'protocol_id')->orderBy('sort_order');
    }

    public function scopeForBusiness($q, int $businessId)
    {
        return $q->where(function ($qq) use ($businessId) {
            $qq->where('business_id', $businessId)->orWhereNull('business_id');
        });
    }
}
