<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\Stock;
use App\Models\Patient;
use App\Models\PatientVaccine;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Vaccine extends Model
{
    use HasFactory;

    protected $table      = 'vaccines';
    protected $primaryKey = 'vaccine_id';
    public $timestamps = false;
    
    protected $fillable = [
        'vac_name',
        // 'vac_price',
        'vac_type',
        "vac_matricule",
        'vac_reg_date',
    ];

    protected $hidden = [ ];

    protected $casts = [
        'vac_reg_date' => 'datetime',
    ];

    public function Stocks(){
        return $this->hasMany(Stock::class, 'vaccine_id', 'vaccine_id');
    }

    public function PatientVaccines(){
        return $this->hasMany(PatientVaccine::class, 'vaccine_id', 'vaccine_id');
    }

    public function Patients(){
        return $this->belongsToMany(Patient::class, "patient_vaccines", 'patient_id', 'vaccine_id')
        ->withPivot([
            'patient_vaccine_id',
            'patient_id',
            'vaccine_id',
            'stock_id',
            "user_id",
            'pav_vaccine_date',
            'pav_status',
            'pav_reg_date'
        ]);
    }


    public function SaleStocks(){
        return $this->belong