Skip to content

Instantly share code, notes, and snippets.

@18601673727
Created July 10, 2014 08:30
Show Gist options
  • Save 18601673727/6a6555d6fd0f78b540fd to your computer and use it in GitHub Desktop.
Save 18601673727/6a6555d6fd0f78b540fd to your computer and use it in GitHub Desktop.
an laravel typical route with fractal.
Route::get('posts/{ids}', function ($ids) {
$ids = explode(',', $ids);
return Post::whereIn('id', $ids)->get();
})->where('ids', '[\d,]+');
Route::get('posts', function () {
return Response::api()->withCollection(Post::all(), new PostTransformer);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment