<?php

namespace App\Models;


use Laravel\Sanctum\HasApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Admin extends Authenticatable
{
    use HasApiTokens;
    
    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    protected $casts = ['pin_ticket' => 'array'];
    
    public function departments()
    {
        return $this->belongsToMany(Department::class, 'admin_department', 'admin_id', 'department_id');
    }
    
    public function supportTickets()
    {
        return $this->hasMany(SupportTicket::class, 'assign_staff_id');
    }
    
    public function pendingSupportTickets()
    {
        return $this->hasMany(SupportTicket::class, 'assign_staff_id')->pending();
    }

}
