<?php

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Cache;
//Notification for Seller
use App\Notifications\SellerResetPasswordNotification;

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
     */
    /*---------*/
    public function isOnline(){
        return Cache::has('user-is-online-'. $this->id);
    }
    protected $hidden = [
        'password', 'remember_token',
    ];

    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');
    }
}
