Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 1.25 KB

readme.md

File metadata and controls

58 lines (43 loc) · 1.25 KB

The bilyiv/restful package

This package under active developing. Please don't use it in production.

Documentation

Filter, sort and embed parameters

Now, you can easily apply query filter, sort and embed parameters to your Eloquent model:

$posts = Post::filter($request->input('filter', []))->get();
$posts = Post::sort($request->input('sort', []))->get();
$posts = Post::embed($request->input('embed', []))->get();

Also, you can shortly paginate their

$paginator = Post::paginateWithParams($request->all());

instead of

$paginator = Post::filter($request->input('filter', []))
    ->sort($request->input('sort', []))
    ->embed($request->input('embed', []))
    ->simplePagination($request->input('limit', 100))
    ->appends($request->all());

Response

You can easily return success response or throw error exception from your controller.

    return $this->response->data($data)->send();
    return $this->response->data($data)->created($location);
    return $this->response->noContent();
    return $this->response->paginated($paginator);
    return $this->response->errorNoFound();