Skip to content

Instantly share code, notes, and snippets.

@deleugpn
Created August 26, 2017 17:26
Show Gist options
  • Save deleugpn/36302893ee0b4686553d8ca8cd29bb86 to your computer and use it in GitHub Desktop.
Save deleugpn/36302893ee0b4686553d8ca8cd29bb86 to your computer and use it in GitHub Desktop.
<?php
/**
* Display a listing of the resource.
*
* @param User $user
* @return \Illuminate\Http\Response
*/
public function index(User $user)
{
return UsersResource::collection($user->with('posts')->paginate());
// If you don't want to include the relationship in your response, don't use with()
// return UsersResource::collection($user->paginate());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment