A
A
Agelios2018-11-15 12:41:08
Laravel
Agelios, 2018-11-15 12:41:08

Update password but not always?

There is a moment in the code when you need to update the user, but update the password only when it is entered.

$data = [..];
if ($request->password){
    $data['password'] = bcrypt($request->password);
}
$user->update($data);

maybe there are better ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex Wells, 2018-11-15
@Agelios

You use FormRequest and after:
And the password of a stall itself will encrypt. Or if not, then you make a mutator in the model.

V
vism, 2018-11-15
@vism

there is, yes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question