0

Within my project, I have given the administrator role the privilege to add users to the site. For security reasons, I hash a random string, to store as the temporary password, I then want to send the user an email with the standard Laravel reset password template.

I have the following:

$user = new User();
$user->name = Input::get('name');
$user->email = Input::get('email');
$user->password = Hash::make(str_random(8));
$user->save();

$response = Password::sendResetLink(Input::get('email'), function (Message $message) {
        $message->subject('Password Reset');
    }); 

The error I'm getting is

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

How can I trigger this function within Laravel, so the user is sent a password reset email? Thank you.

2
  • I think the error is pretty self-explanatory. The sendResetLink expects an array and you're providing a string. Commented Apr 17, 2016 at 19:02
  • @PawelMysior, very true, that is the problem I am having. I'm unsure of what it wants within the Array. Commented Apr 17, 2016 at 19:08

1 Answer 1

1

The problem here is that you are sending string email, and you should send array (this is what error says).

You should in this case use:

Request::only('email')

instead of

Input::get('email')
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for you reply. I tried this but the following error is returned Non-static method Illuminate\Http\Request::only() should not be called statically, assuming $this from incompatible context.
@Ben So change Request here into \Request to use Request facade here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.