<?php

namespace Modules\ClinicLab\Entities;

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

/**
 * An external reference-lab / outreach provider sending samples to this lab.
 * business_id scoped.
 */
class CllOutreachProvider extends Model
{
    protected $table = 'cll_outreach_providers';

    protected $fillable = [
        'business_id', 'name', 'contact_person', 'phone', 'email',
        'address', 'price_group_note', 'is_active',
    ];

    protected $casts = [
        'is_active' => 'boolean',
    ];

    public function orders(): HasMany
    {
        return $this->hasMany(CllOutreachOrder::class, 'provider_id');
    }

    public function scopeForBusiness($query, $businessId)
    {
        return $query->where('business_id', $businessId);
    }
}
