File: /var/www/vhost/disk-apps/alq-central.bikenow.co/app/User.php
<?php
namespace App;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Schedula\Laravel\PassportSocialite\User\UserSocialAccount;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Notifications\Messages\MailMessage;
use App\Rol;
use App\UserInformation;
class User extends Authenticatable implements UserSocialAccount
{
use HasApiTokens, Notifiable, SoftDeletes;
protected $dates = ['deleted_at'];
public function rol()
{
return $this->belongsTo(Rol::class)->select(array('id', 'name'));
}
public function userInfo()
{
return $this->hasOne(UserInformation::class);
}
public function addresses()
{
return $this->hasMany(Address::class);
}
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* Find user using social provider's id
*
* @param string $provider Provider name as requested from oauth e.g. facebook
* @param string $id User id of social provider
*
* @return User
*/
public static function findForPassportSocialite($provider, $id)
{
$account = UserInformation::where('social_provider', $provider)->where('social_id', $id)->first();
$userAccount = User::find($account->user_id);
if ($userAccount) {
return $userAccount;
}
return;
}
/**
* Sends the password reset notification.
*
* @param string $token
*
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new CustomPassword($token));
}
}
class CustomPassword extends ResetPassword
{
public function toMail($notifiable)
{
return (new MailMessage)
->from(env('MAIL_USERNAME'))
->subject('Restablecer contraseña ' . env('MAIL_FROM_NAME'))
->greeting('Hola,')
->line('Te estamos enviando este email porque hemos recibido una solicitud de restablecer tu contraseña.')
->action('Restablecer contraseña', url(config('app.url') . route('password.reset', $this->token, false)))
->line('Si no has solicitado restablecer la contraseña, no es necesario realizar ninguna acción. Por favor contáctanos si tu no enviaste esta solicitud.');
}
}