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.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire