<?php

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

//Notification for Seller
use App\Notifications\SellerResetPasswordNotification;
use Cache;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'username', 'email', 'password', 'status', 'last_login', 'created_at', 'updated_at'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /*---------*/
    public function isOnline(){
        return Cache::has('user-is-online-'. $this->id);
    }

    public function sendPasswordResetNotification($token)
    {
        $this->notify(new SellerResetPasswordNotification($token));
    }
    function mgroups(){
        return $this->belongsToMany('App\Models\Role', 'user_roles');
    }
    function roles(){
        return $this->belongsToMany('App\Models\Role', 'user_roles');
    }
    function ro()
    {
        return $this->hasOne('App\Models\UserRole','user_id');
    }
}
