<br />
<b>Warning</b>:  Undefined variable $auth in <b>/home/pevo0181/public_html/pia-soft.com/cleania/routes/index.php</b> on line <b>542</b><br />
<br />
<b>Warning</b>:  Trying to access array offset on value of type null in <b>/home/pevo0181/public_html/pia-soft.com/cleania/routes/index.php</b> on line <b>542</b><br />
<?php

namespace App\Models;

use App\Models\User;
use App\Models\Region;
use App\Models\Report;
use App\Models\Equipment;
use App\Models\Department;
use App\Models\Subdivision;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;

class Agence extends Model
{
    use HasFactory;

    protected $table      = 'agences';
    protected $primaryKey = 'agence_id';
    public $timestamps    = false;

    protected $fillable = [
        'region_id',
        'department_id',
        'subdivision_id',
        'ag_latitude',
        'ag_longitude',
        'ag_name',
        'ag_category',
        'ag_agence_status',
        'ag_owner_name',
        'ag_owner_phone',
        "ag_tech_manager_name" ,
        "ag_tech_manager_phone",
        'ag_is_energy',
        'ag_energy_duration',
        'ag_vaccine_strategy',
        'ag_population',
        'ag_vaccine_storage_type',
        'ag_advance_strategy_number',
        'ag_network_operator',
        "ag_other_operator",
        'ag_supply_depot_duration',
        'ag_supply_depot_distance',
        'ag_icon',
        'ag_matricule',
        "ag_agence_number",
        'ag_status',
        'ag_register_date',
    ];

    protected $hidden = [ ];
    protected $casts  = [
        'ag_register_date' => 'datetime:Y-m-d H:i:s',
    ];

    public function Users()
    {
        return $this->hasMany(User::class, 'agence_id', 'agence_id');
    }

    public function Region()
    {
        return $this->belongsTo(Region::class, 'region_id', 'region_id');
    }

    public function Department()
    {
        return $this->belongsTo(Department::class, 'department_id', 'department_id');
    }

    public function Subdivision()
    {
        return $this->belongsTo(Subdivision::class, 'subdivision_id', 'subdivision_id');
    }

    public function Equipments()
    {
        return $this->hasMany(Equipment::class, 'agence_id', 'agence_id');
    }

    public function PreventiveReports()
    {
        return $this->hasMany(PreventiveReport::class, 'agence_id', 'agence_id');
    }

    public function Reports(): HasManyThrough
    {
        return $this->hasManyThrough(
          