edhbs
1 month ago

My If-Else Didn't Work in Laravel

Posted 1 month ago by edhbs

When i run on if it is totally work, but when i run on else if it didn't work anyone know?

  public function updateFile(Request $request,$id)
    {
        $detail_data= \App\cv::find($id);
            
        if($request==true)
        {   $exe1=$request->has('judul');
            $exe2=$request->has('keterangan');
            if($exe1==false&&$exe2==true){
                $ex1=$request->except(['judul']);
                $detail_data->update($ex1);
                
                return redirect('/admin')->with('sukses','Data Successfully Updated');

                }
            else if($exe2==false&&$exe1==true)
            {
                $ex2=$request->except(['keterangan']);
                $detail_data->update($ex2);
                
                return redirect('/admin')->with('sukses','Data Successfully Updated');
            }
            else{
                $detail_data->update($request->all());
                return redirect('/admin')->with('sukses','Data Successfully Updated');
                }
        
        }
    }

Please sign in or create an account to participate in this conversation.