Dkna
Dkna

Reputation: 437

Wrong redirect when data have been submitted using if else laravel

I am trying to get a request from the input I just got where if the request input recommendation is No or KIV, it will redirect to home if not it will redirect to another page. But the problem now is that if the recommendation I put is Yes and some other things as No, it will redirect me to home instead of another page. Can someone help me out? Thanks a lot

    public function eval(Request $request){
     $Evaluation = new evaluation;
        $personal_info = new personal_info;
        $Evaluation->recommendation = $request->input('recommendation');
        $Evaluation->training_schedule = $request->input('training_schedule');
        $Evaluation->training_date = $request->input('training_date');
        $Evaluation->PortalLogin = $request->input('PortalLogin');
        $id = $request->user_id;
        $id= personal_info::find($id);
        $id->evaluations()->save($Evaluation);

        if(($Evaluation->recommendation = $request->input('recommendation')) == 'No' || 'KIV')
            return redirect('/home');
        else{
    return redirect(url('/user/showtest/'.$id->id.'/test) );
}

Upvotes: 0

Views: 16

Answers (1)

nithinTa
nithinTa

Reputation: 1642

They syntax of your "if statement" is incorrect. || 'Kiv' this statement is evaluated alone and not against recommendation, so change the code to this way

$recommendation = $Evaluation->recommendation = $request->input('recommendation');

if( $recommendation == 'No' || $recommendation == 'KIV')
    return redirect('/home');
else {
    return redirect(url('/user/showtest/'.$id->id.'/test) );
}

Upvotes: 1

Related Questions