【问题标题】:As the file path changes password.blade in laravel?随着文件路径在laravel中更改password.blade?
【发布时间】:2016-05-21 17:02:21
【问题描述】:

我正在做一个简单的应用程序 laravel 5.1,我想为用户重置密码。我对此没有意见。

我只是还没有找到改变某些文件路径的方法。 其中包括文件“password.blade.php”,它是发送到包含令牌链接的用户邮件的文件。该文件必须在 Resources / views / emails / route 中。

您想更改:文件的名称和路径。 ? 或者您是否可以选择要发送的其他视图?

谢谢您,任何信息将不胜感激)。

【问题讨论】:

  • 我知道这不是您要问的,但您为什么不能在文件内进行编辑以便发送不同的视图?
  • 我只想更改文件的位置。例子我要放到auth文件夹里,可以是?。我正在使用 laravel 提供的方法:(getEmail、postEmail、getReset、postReset)。如文档中所述。
  • 你能解释一下吗?您只是想重新定位您的password.blade.php 文件?正确的?并且您还希望他们从新位置访问此文件?

标签: php email laravel-5.1 reset-password


【解决方案1】:

PasswordBroker 中有一个 $emailView 变量。

/**
 * The view of the password reset link e-mail.
 *
 * @var string
 */
protected $emailView;

如果您在密码控制器中将此设置为您的视图,您应该能够更改它的路径和名称。

如果它不起作用,您可以覆盖密码控制器中的 emailResetLink 函数并在那里更改视图。这是来自 Laravel 5.2 的。如果不同,您可以从 PasswordBroker.php 获得 5.1。

/**
 * Send the password reset link via e-mail.
 *
 * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
 * @param  string  $token
 * @param  \Closure|null  $callback
 * @return int
 */
public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null)
{
    // We will use the reminder view that was given to the broker to display the
    // password reminder e-mail. We'll pass a "token" variable into the views
    // so that it may be displayed for an user to click for password reset.
    $view = $this->emailView;

    return $this->mailer->send($view, compact('token', 'user'), function ($m) use ($user, $token, $callback) {
        $m->to($user->getEmailForPasswordReset());

        if (! is_null($callback)) {
            call_user_func($callback, $m, $user, $token);
        }
    });
}

【讨论】:

  • 非常感谢你帮了我很多。在 PasswordBroken 文件中创建一个更改 emailview 变量值的新方法。 $this->emailView = $value;但是还有另一种方法可以从控制器更改此变量的值吗?尝试密码 :: emailview 并没有工作。我是新来的(。非常感谢。
  • 我也想到向函数添加一个新参数,但如果编辑东西是正确的,则不是。你关于这个朋友??
  • 没问题。您是否尝试在 PasswordController 中将受保护的 $emailView 设置为您的视图?这就是从 emailResetLink 函数中检索到的内容。
猜你喜欢
  • 2019-01-23
  • 1970-01-01
  • 2020-07-03
  • 2017-10-28
  • 2014-03-05
  • 1970-01-01
  • 1970-01-01
  • 2015-02-27
  • 1970-01-01
相关资源
最近更新 更多