<?php

namespace App;

use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{

    use HasApiTokens,
        Notifiable;

    protected $table = 'users';
    protected $primaryKey = 'id';
    public $timestamps = false;
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        //'email_verified_at' => 'datetime',
    ];

    // protected $attributes = [
    //     'status' => 0,
    // ];

    public function menus()
    {
        return $this->hasMany('App\UserMenus', "users_id","id");
    }
    public function data()
    {
        return $this->hasManyThrough('App\Menus', 'App\UserMenus', "users_id", "id", "id", "menus_id");
    }
    public function franchise()
    {
        return $this->belongsTo('App\Franchises', 'FKFranchiseID', 'PKFranchiseID');
    }



    public function getStatusAttribute($value)
    {
        return $value ? 'Active' : 'Inactive';
    }

    // Define the mutator
    public function setStatusAttribute($value)
    {
        $this->attributes['status'] = $value ? 1 : 0;
    }
}