“密码重置令牌无效”的覆盖错误文本Laravel

时间:2019-09-23 17:03:33

标签: laravel

如果密码重置令牌已过期,我需要覆盖错误消息。但默认情况下,它显示“密码重置令牌无效”,但我需要使用其他文本。我使用Laravel 5.6

我试图找到方法,但是在这里或在官方文档上都没有找到任何信息。

非常感谢您的帮助或技巧,

2 个答案:

答案 0 :(得分:1)

您可以在resources/lang/en/passwords.php中的文件中找到翻译字符串。

这还确保您可以将此字符串转换为您使用的其他语言。

<?php
return [
    /*
    |--------------------------------------------------------------------------
    | Password Reset Language Lines
    |--------------------------------------------------------------------------
    |
    | The following language lines are the default lines which match reasons
    | that are given by the password broker for a password update attempt
    | has failed, such as for an invalid token or invalid new password.
    |
    */
    'reset' => 'Your password has been reset!',
    'sent' => 'We have e-mailed your password reset link!',
    'token' => 'This password reset token is invalid.',
    'user' => "We can't find a user with that e-mail address.",

This file

答案 1 :(得分:1)

在刀片模板中,而不是

@if ($errors->has(field))
    <span class="help-block">
        <strong>{{ $errors->first(field) }}</strong>
    </span>
@endif

您可以使用此

@if ($errors->has(field))
    <span class="help-block">
        <strong>{{ sprintf('Error Message')}}</strong>
    </span>
@endif