samedi 28 novembre 2015

Laravel 5 Eloquent: do not contain all fields after saving

for example there are 4 files in table users:
name | avatar | created_at | updated_at
when user model is saved with only name:

public function reg(){
  $user = new User; 
  $user->name = 'aName';    
  $user->save();
  return response()->json($user);
}

then I get the response json:

{
  "id":1;
  "name":"aName",
  "created_at":"xxxxxxxx",
  "updated_at":"xxxxxxxx"
}

there is no filed avatar, I want the response also contains avatar filed even I did not set value for it.



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

Aucun commentaire:

Enregistrer un commentaire