3

I have a Laravel 5.4 application and I have a view in my admin area that allows me to see all users.

I want to create a function that allows me to click a button in the back end that automates the process of sending the default Laravel password reset functionality.

In my view I have the following:

<table class="table table-hover"> <thead> <th>#</th> <th>Company</th> <th>Name</th> <th>Email Address</th> <th>Action</th> </thead> <tbody> @foreach(\App\User::all() as $c) <tr> <td>{{ $c->id }}</td> <td>{{ $c->company->company_name }}</td> <td>{{ $c->name }}</td> <td>{{ $c->email }}</td> <td><a href="/admin/user/{{ $c->id }}/password/reset">Password Reset</a></td> </tr> @endforeach </tbody> </table> 

On the link click for resetting the password this currently via my routes hits the following function

public function passwordReset($id) { $user = User::FindOrFail($id); Password::sendResetLink($user->email); } 

I'm not to familiar with Laravels default password reset functionality so I'm probably way off but I get the following error:

Argument 1 passed to Illuminate\Auth\Passwords\PasswordBroker::sendResetLink() must be of the type array, string given,

3
  • You need to pass in an array of credentials, not a string. Commented Mar 14, 2017 at 10:54
  • Thanks @Ian out of interest if this is a send password reset function why would I need to pass the password? surely this is being reset by the user? Commented Mar 14, 2017 at 11:03
  • You don't need to pass the password. Commented Mar 14, 2017 at 11:32

1 Answer 1

10

You need to send an array with email as key:

Password::sendResetLink(['email' => $user->email]); 
Sign up to request clarification or add additional context in comments.

1 Comment

So much easier than in 5.2!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.