zoukankan      html  css  js  c++  java
  • laravel 5.5 修改auth 重置密码邮件

    1.输入 php artisan make:notification RestPassword ,在 app otification 下创建 RestPassword.php

    然后修改 AppUser:

    namespace App;
    
    use IlluminateNotificationsNotifiable;
    use IlluminateFoundationAuthUser as Authenticatable;
    use AppNotificationsResetPassword as RestPasswordNotification; // 替换 
    
    class User extends Authenticatable
    {
        use Notifiable;
    
        /**
         * The attributes that are mass assignable.
         *
         * @var array
         */
        protected $fillable = [
            'name', 'email', 'password', 'college', 'class', 'phone'
        ];
    
        /**
         * The attributes that should be hidden for arrays.
         *
         * @var array
         */
        protected $hidden = [
            'password', 'remember_token',
        ];
    
        public function sendPasswordResetNotification($token)
        {
            $this->notify(new RestPasswordNotification($token));
        }
    }

     2.输入 php artisan vendor:publish --tag=laravel-notifications 

    将自动创建 email.blade.php 模版,我这里并不想修改 

    3.更改邮件内容,修改第一步创建的 app otificationRestPassword.php  

    namespace AppNotifications;
    
    use IlluminateBusQueueable;
    use IlluminateNotificationsNotification;
    use IlluminateContractsQueueShouldQueue;
    use IlluminateNotificationsMessagesMailMessage;
    
    class ResetPassword extends Notification
    {
        use Queueable;
    
        /**
         * The password reset token.
         *
         * @var string
         */
        public $token;
    
        /**
         * Create a new notification instance.
         *
         * @return void
         */
        public function __construct($token)
        {
            $this->token = $token;
        }
    
        /**
         * Get the notification's delivery channels.
         *
         * @param  mixed  $notifiable
         * @return array
         */
        public function via($notifiable)
        {
            return ['mail'];
        }
    
        /**
         * Get the mail representation of the notification.
         *
         * @param  mixed  $notifiable
         * @return IlluminateNotificationsMessagesMailMessage
         */
        public function toMail($notifiable)
        {
            return (new MailMessage)
                        ->subject('XXXX')
                        ->salutation('XXX')
                        ->line('您之所以收到这封邮件是因为我们收到了您重置密码的申请。')
                        ->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
                        ->line('如果您本人未进行密码重置,您可以不必采取进一步操作!');
        }
    
    }
    沿着 IlluminateNotificationsMessagesMailMessage 可以找到 IlluminateNotificationsMessagesSampleMessage 
    其中包含了 subject, salutation ...
  • 相关阅读:
    畅销书排行榜
    阿里云大数据产品体系
    天然气收费管理系统的研究与实现随笔
    Web端实现RTC视频特效的解决方案
    从0搭建在线聊天室,只需4步!
    技术干货 | JavaScript 之事件循环(Event Loop)
    C++20 四大特性之一:Module 特性详解
    Android Flutter 多实例实践
    网易云信线上万人连麦技术大揭秘
    Python + Pytest 自动化框架的用例依赖实操
  • 原文地址:https://www.cnblogs.com/navysky/p/7730041.html
Copyright © 2011-2022 走看看