Created
July 13, 2019 14:04
-
-
Save hieuhani/e16e5ea4b92219136c7343018c858fd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use App\Notifiable; | |
use Illuminate\Auth\Authenticatable; | |
use Illuminate\Auth\Passwords\CanResetPassword; | |
use Laravel\Lumen\Auth\Authorizable; | |
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; | |
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; | |
use Tymon\JWTAuth\Contracts\JWTSubject; | |
use Illuminate\Contracts\Auth\CanResetPassword as ResetPasswordContract; | |
use App\Notifications\ResetPassword as ResetPasswordNotification; | |
class User extends ModelAbstract implements AuthenticatableContract, AuthorizableContract, JWTSubject, ResetPasswordContract | |
{ | |
use Authenticatable, Authorizable, CanResetPassword, Notifiable; | |
/** | |
* The attributes that are mass assignable. | |
* | |
* @var array | |
*/ | |
protected $fillable = [ | |
'name', 'email', 'password', 'branch_id' | |
]; | |
/** | |
* The attributes excluded from the model's JSON form. | |
* | |
* @var array | |
*/ | |
protected $hidden = [ | |
'password', 'remember_token' | |
]; | |
/** | |
* The accessors to append to the model's array form. | |
* | |
* @var array | |
*/ | |
protected $appends = [ | |
'photo_url', | |
]; | |
/** | |
* Get the profile photo URL attribute. | |
* | |
* @return string | |
*/ | |
public function getPhotoUrlAttribute() | |
{ | |
return 'https://www.gravatar.com/avatar/'.md5(strtolower($this->email)).'.jpg?s=200&d=mm'; | |
} | |
public function sendPasswordResetNotification($token) | |
{ | |
$this->notify(new ResetPasswordNotification($token)); | |
} | |
public function getJWTIdentifier() | |
{ | |
return $this->getKey(); | |
} | |
public function getJWTCustomClaims() | |
{ | |
return []; | |
} | |
public function groups() | |
{ | |
return $this->belongsToMany('App\Models\Group'); | |
} | |
public function branch() | |
{ | |
return $this->belongsTo('App\Models\Branch'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment