Using accessors and mutators in Laravel json responses
Yeah there is, example:
return Response::json([User:all()], 200);
Usually you want more than that though..
return Response::json([ 'error' => false, 'data' => User:all()], 200);
200
is the HTTP Status Code.
To include the attributes you need to specify these attributes to automatically append onto the response in your model.
protected $appends = array('foo');public function getFooAttribute(){ return 'bar'; }