Created
June 26, 2017 23:06
-
-
Save giordanolima/a3d74599aa7dfdacfdd3ef0e9e391041 to your computer and use it in GitHub Desktop.
Usuarios Model personalizado
This file contains 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\Usuarios; | |
use Illuminate\Auth\Authenticatable; | |
use Illuminate\Auth\Passwords\CanResetPassword; | |
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; | |
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Support\Facades\Hash; | |
use Illuminate\Notifications\Notifiable; | |
class Usuarios extends Model implements AuthenticatableContract, CanResetPasswordContract { | |
use Authenticatable, | |
CanResetPassword, | |
Notifiable; | |
protected $table = 'tb_usuarios'; | |
protected $primaryKey = 'usuario_id'; | |
protected $guarded = ['usuario_id']; | |
public $timestamps = false; | |
// --------------------------------- | |
// ------------- AUTH -------------- | |
// --------------------------------- | |
public function setUsuarioSenhaAttribute($senha) { | |
$this->attributes['usuario_senha'] = Hash::make($senha); | |
} | |
public function getAuthIdentifier() { | |
return $this->usuario_id; | |
} | |
public function getAuthPassword() { | |
return $this->usuario_senha; | |
} | |
public function getRememberToken() { | |
return $this->usuario_token; | |
} | |
public function getRememberTokenName() { | |
return 'usuario_token'; | |
} | |
public function getEmailForPasswordReset() { | |
return $this->usuario_email; | |
} | |
public function sendPasswordResetNotification($token) { | |
$this->notify(new \App\Notifications\ResetPassword($token)); | |
} | |
public function routeNotificationForMail() { | |
return $this->usuario_email; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment