laravel5找回密码改中文

作者: 刘满 分类: laravel 发布时间: 2018-12-02 20:33

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

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据