Provides laravel scope to build query from request query params
jwohlfert23/laravel-api-query is a Laravel package for provides laravel scope to build query from request query params.
It currently has 0 GitHub stars and 16.073 downloads on Packagist (latest version 6.1.0).
Install it with composer require jwohlfert23/laravel-api-query.
Discover more Laravel packages by jwohlfert23
or browse all Laravel packages to compare alternatives.
Last updated
composer require jwohlfert23/laravel-api-query
This package is implemented as a trait, which provides the buildFromRequest scope.
use Jwohlfert23\LaravelApiQuery\BuildQueryFromRequest;
class Post {
use BuildQueryFromRequest;
}
Post::buildFromRequest()->get();
is the same as:
Post::orderByDesc('id')->orderBy('name');
is the same as:
Post::where('name', 'Bobby')->whereHas('author', function($q) {
$q->where('name', 'like', '%Bob%');
});
Note: this package doesn't use "whereHas", but rather performs left joins internally. However, the results should be the same as the above code.
Filters default to using the "equal" operator. These are the operators available to use in filtering (contains is use above).
is the same as
Post::with('author','comments');