xydens / laravel-rsq
There is no license information available for the latest version (0.1.0) of this package.
Laravel Remote Structured Queries
0.1.0
2019-01-16 15:59 UTC
Requires
- laravel/framework: ^5.4
This package is not auto-updated.
Last update: 2024-09-20 03:14:35 UTC
README
As SQL but JSON and safe(probably)
Concept
Specify models selection and representation through special query
field. Query is special json
structure like:
{
"filter": {
"is_confirmed": 1,
"age": {
"sign": ">=",
"value": "18"
}
},
"sort": {
"age": "asc"
}
}
Setup
- Add
Xydens\LaravelRSQ\RSQServiceProvider::class
toproviders
- Optionally add
"RSQ" => Xydens\LaravelRSQ\Factory::class
toaliases
- Add
Xydens\LaravelRSQ\RemoteQueryable
trait to models, what you want to query
Usage
Simple example
In your controller:
use App/User; //Model
use Illuminate\Http\Request;
use RSQ;
class UserController extends Controller
{
public function query(Request $request){
$query = RSQ::requestOrSession($request,User::class);
return Review::RSQ($query)->get();
}
}
Now you can add qurey
field to request.