dimanche 19 février 2017

Can't update table in larave 5.4 using Elequent query

I am using Laravel 5.4. I made a function for two (insert and update). When id is not found it will hit inset otherwise it will hit update method. Everything is working well but the update elequent query is not updating the table. The method is for angularjs http.post method

Controller function:

public function postUserJson(Request $req)
    {

    //return "check". $req->input('id');






   if ($req->input('id')==''){
        $user = new User();
        $user->UserName = $req->input('username');
        $user->Password = $req->input('password');

    $user->save();
       return "inserted";
   }

   else {

       $check= User::find($req->input('id'));

      // $check->ID = $req->input('id');
       $check->UserName = $req->input('username');
       $check->Password = $req->input('password');

       $check->save();
       return "updated".$check;

   }

This ( return "updated".$check;) code return in console:

 updated{"ID":13,"UserName":"sadek","Password":"456"}

enter image description here

Previous username was sade. After editing i got the edited name with sadek after save() method. But when i refresh it show sade

How can i update a table ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lwHLos
via IFTTT

Aucun commentaire:

Enregistrer un commentaire