<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\Card;
use App\Models\User;
use App\Models\Region;
use App\Models\Department;
use App\Models\Appointment;
use App\Models\Subdivision;
use App\Models\Vaccination;
use App\Models\CardRegenerated;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Center extends Model
{
    use HasFactory, SoftDeletes;

    protected $table        = 'centers';
    protected $primaryKey   = 'center_id';

    protected $fillable = [
        "region_id",
        "department_id",
        "subdivision_id",
        "ctr_name",
        "ctr_phone",
        "ctr_email",
        "ctr_address",
        "ctr_latitude",
        "ctr_longitude",
        "ctr_icon",
        "ctr_matricule",
        "ctr_type",
        "ctr_status"
    ];

    const CREATED_AT = 'ctr_created_at';
    const UPDATED_AT = 'ctr_updated_at';
    const DELETED_AT = 'ctr_deleted_at';

    protected $casts = [
        'ctr_created_at' => 'datetime:Y-m-d m:i:s',
        'ctr_updated_at' => 'datetime:Y-m-d m:i:s',
        'ctr_deleted_at' => 'datetime:Y-m-d m:i:s',
    ];


    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 Appointments()
    {
        return $this->hasMany(Appointment::class, 'center_id','center_id');
    }

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

    public function Cards()
    {
        ret