Laravel update form

Judikael :

Hello i'm using laravel and i'm using a specific method for users, seller and another type of user.

So if i'm updating a form of users ( them contain : pseudo, password, if the seller have paid ad another field ) the password was updated if the field is null, and i don't want this and i can't show the password because laravel use bcrypt for hash password and we can only verify if the hash is the same as a password entered as a plain text.

My problem is really specific, i have serch solution but no on have the same problem. Any solution ?

 public function update(Request $request,$id)
{
    $inputs = $request->all();
    dd($inputs);
    $seller = Seller::find($id);
    $seller->pseudo = $inputs['pseudo'];
    $seller->password = Hash::make($inputs['password']);
    $seller->token_related_product = $inputs['token_related_product'];
    $seller->save();
    return view('backend.home');
}
Dan :

If you only want to set a new passwort if the password field is filled, just compare the value of the field to an empty string. If it's not empty, hash the password and save it to the database, otherwise skip this step.

public function update(Request $request,$id)
{
    $inputs = $request->all();

    $seller = Seller::find($id);
    $seller->pseudo = $inputs['pseudo'];

    if ($request->filled('password')) {
        $seller->password = Hash::make($inputs['password']);
    }

    $seller->token_related_product = $inputs['token_related_product'];
    $seller->save();

    return view('backend.home');
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=386614&siteId=1