I\'m currently working on a project where I\'m writing an API, and with a lot of the models, I\'m trying to hide their parent relationships from being returned, like so
protected $hidden = array(
'id', 'user_id', 'user'
^^^ relationship's method name which is "user"
);
if you want to hide the relationship , you have to include method name
under hidden attributes. From your hidden attributes, i can see, you are perfectly hiding user
relationship from Array and JSON conversion . However, if you have 'user' column in your users_tokens
table, I have no idea what Laravel will behave.
public function user() {
return $this->belongsTo('User');
}