Created
February 5, 2020 19:10
-
-
Save ambrosiora/c6a8da78e2fa41af0d5274c77248e60d 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; | |
use Illuminate\Contracts\Auth\MustVerifyEmail; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
use Illuminate\Notifications\Notifiable; | |
use Tymon\JWTAuth\Contracts\JWTSubject; | |
use Illuminate\Database\Eloquent\Model; | |
class User extends Authenticatable implements JWTSubject | |
{ | |
use Notifiable; | |
/** | |
* The attributes that are mass assignable. | |
* | |
* @var array | |
*/ | |
protected $fillable = [ | |
'nome', 'email', 'password', | |
]; | |
/** | |
* The attributes that should be hidden for arrays. | |
* | |
* @var array | |
*/ | |
protected $hidden = [ | |
'password', 'remember_token', | |
]; | |
/** | |
* The attributes that should be cast to native types. | |
* | |
* @var array | |
*/ | |
protected $casts = [ | |
// 'email_verified_at' => 'datetime', | |
]; | |
/** | |
* Get the identifier that will be stored in the subject claim of the JWT. | |
* | |
* @return mixed | |
*/ | |
public function getJWTIdentifier() | |
{ | |
return $this->getKey(); | |
} | |
/** | |
* Return a key value array, containing any custom claims to be added to the JWT. | |
* | |
* @return array | |
*/ | |
public function getJWTCustomClaims() | |
{ | |
return [ | |
'id' => $this->id, | |
'nome' => $this->nome | |
]; | |
} | |
public function sistemas() | |
{ | |
return $this->belongsToMany('App\Sistema', 'user_sistema_papel_usuarios')->withPivot('papel_usuario_id'); | |
} | |
public function papelUsuarios() | |
{ | |
return $this->belongsToMany('App\PapelUsuario', 'user_sistema_papel_usuarios')->withPivot('sistema_id'); | |
} | |
// public function newPivot(Model $parent, array $attributes, $table, $exists, $using = NULL) | |
// { | |
// if ($parent instanceof PapelUsuario) { | |
// return new PapelUsuarioGroupPivot($attributes, $table, $exists); | |
// } | |
// if ($parent instanceof Sistema) { | |
// return new SistemaGroupPivot($attributes, $table, $exists); | |
// } | |
// return parent::newPivot($parent, $attributes, $table, $exists); | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment