0

How to pass the custom variables from ResetPasswordController to reset blade template.

ResetPasswordController.php

 public function showResetForm(Request $request, $token = null)
 {
    $data = array(
        'title'=>'Reset password',
        'description'=> 'Reset password to abc.com',
        'seo_keywords'=> 'Reset password to abc.com',
      );
      return view('auth/password/reset',$data);

 }
Upasana Chauhan
  • 948
  • 1
  • 11
  • 32

1 Answers1

1

By returning a view(), the second argument can be used to pass variables to the blade template (just like you have done)

public function showResetForm(Request $request, $token = null)
{
    return view('auth/password/reset',[
        'title'         =>'Reset password',
        'description'   => 'Reset password to abc.com',
        'seo_keywords'  => 'Reset password to abc.com',
    ]);
}

These would then be accessable as {{ $title }}, {{ $description}}, {{ $seo_keywords}}.

If you are unable to retrieve these, it may be because you are editting the wrong blade template. The default template is located at auth.passwords.reset (resources/views/auth/passwords/reset.blade.php).

I'd suggest just adding a {{ dd('here) }} at the top of that template to make sure it is in fact the template being used by your application!

Spholt
  • 3,724
  • 1
  • 18
  • 29
  • thanks! how can do the same for Forgotpasswordcontroller I am not able to find the showResetForm function... – Upasana Chauhan Feb 21 '20 at 17:20
  • The default view is inherited from the `SendsPasswordResetEmails` trait. You can overide this by adding a `showLinkRequestForm()` function to your `ForgotPasswordController`. it is using `'auth.passwords.email'` as the default template – Spholt Feb 21 '20 at 17:24