jeudi 23 janvier 2020

How to make validation if password NULL (no password detected), if have password (password required)

Its My Function in Delete,i click button delete not checking if password are null or not, i wanted to make it different validation. if he no set a password or password null = message password not been set. other do hash check if password same or not(it's working only for checked password hash )

public function deleteOper(Request $request, $id){

    $buletin = \App\Bulletin::find($id);
    $getPosting = Bulletin::select('password')->where('id', $id)->get();

    $cPass = $request->passwordC;
    $url = "/?page={$request->page}";

    if($getPosting->password!=null){

        return redirect('home');
    }

    if (hash::check($cPass,$buletin->password)){
        return view ('bulletin.delete', ['buletin' => $buletin, 'url'=> $url]);//save and go back to card

} else {

    $request->validate([
        'passwordC' => 'required|required_with:password|same:password'
        ],[
        'passwordC.required_with' => "Password not match",
        'passwordC.required' => "Password Required",
        'passwordC.same' => "The Password You Entered Do Not Match.Please Try Again"
            ]);
        }
}

Aucun commentaire:

Enregistrer un commentaire