5.7
lang/zh_cn.json
{ "Login": "登陆", "E-Mail Address": "邮箱", "Password": "密码", "Remember Me": "记住我", "Forgot Your Password?": "忘记密码?", "Register": "注册", "Name": "姓名", "Confirm Password": "重复密码", "Reset Password": "重设密码", "Send Password Reset Link": "发送邮件", "Logout": "退出", "Reset Password Notification": "找回密码", "You are receiving this email because we received a password reset request for your account.": "您收到此电子邮件,因为我们收到了找回密码请求您的账户。", "If you did not request a password reset, no further action is required.": "如果没有请求找回密码,则不需要进一步的操作。", "Hello!": "您好!", "Regards": "真挚问候", "If you’re having trouble clicking the ": "如果您不能点击" }
5.4
php artisan vendor:publish --tag=laravel-notifications//找回密码邮件模版 php artisan make:notification ResetPassword//找回密码邮件通知
App/Notifications/Resetpassword.php
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; class ResetPassword extends Notification { use Queueable; /** * The password reset token. * * @var string */ public $token; /** * Create a notification instance. * * @param string $token * @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 \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { return (new MailMessage) ->subject('找回密码') ->line('您收到此电子邮件,因为我们收到了找回密码请求您的账户。') ->action('重设密码', route('password.reset', $this->token)) ->line('如果没有请求找回密码,则不需要进一步的操作。'); } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { return [ // ]; } }
app\User.php
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; use App\Notifications\ResetPassword as ResetPasswordNotification; class User extends Authenticatable { use Notifiable; /** * 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', ]; public function sendPasswordResetNotification($token) { $this->notify(new ResetPasswordNotification($token)); } }
views/vendor/notifications/email.blade.php
@component('mail::message') {{-- Greeting --}} @if (! empty($greeting)) # {{ $greeting }} @else @if ($level == 'error') # 错误! @else # 您好! @endif @endif {{-- Intro Lines --}} @foreach ($introLines as $line) {{ $line }} @endforeach {{-- Action Button --}} @if (isset($actionText)) <?php switch ($level) { case 'success': $color = 'green'; break; case 'error': $color = 'red'; break; default: $color = 'blue'; } ?> @component('mail::button', ['url' => $actionUrl, 'color' => $color]) {{ $actionText }} @endcomponent @endif {{-- Outro Lines --}} @foreach ($outroLines as $line) {{ $line }} @endforeach <!-- Salutation --> @if (! empty($salutation)) {{ $salutation }} @else 来自,<br>{{ config('app.name') }} @endif <!-- Subcopy --> @if (isset($actionText)) @component('mail::subcopy') 如果您不能点击"{{ $actionText }}"按钮,请复制下面的网址粘贴到您的浏览器: [{{ $actionUrl }}]({{ $actionUrl }}) @endcomponent @endif @endcomponent