简体   繁体   中英

why i m null getting value in laravel

here is my controller i don't know why i have null value i check using dd($user)

  public function success1(Request $request)
   { 

   $phonetoken = $request->input('phonetoken');

      $user =User::where('phonetoken', $phonetoken)->first();


       dd($user);
        if(!is_null($user)){
        $user->phoneconfirmed = 1;
        $user->phonetoken = " ";
        $user->save();

       return redirect('sellerdashboard');
       }

       return redirect()->back();
     } 

why im not getting value in $user always getting null

Thats probably because your eloquent cannot find the result. Use dd($phonetoken) just to be sure the variable is being passed properly. Also check phonetoken is in your user model. Othet than this your code seems to be correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM