Laravel package for REST API creation.
Via Composer
$ composer require Talk-Point/TPREST
In the Controller use
try {
$models = RESTQuery::create(TestModel::class)->query()->get();
return response()->json($models);
} catch (QueryException $e) {
return response()->json(['message' => 'DB Query Exception', 'invalid' => $e->errorInfo[2]], 422);
} catch (Exception $e) {
return response()->json(['message' => 'DB Query Exception'], 422);
}
You can combine the parameter to a big search.
Easy search in columns
http://localhost:8001/tests?title=Prof
Options:
Filter Parameter with format column=filter;option
http://localhost:8001/tests?title=Prof;!like&sortby=id;desc&number_integer=3;%3C%3E&title=Dr.
Possible Options: equal
=
<
>
<=
>=
<>
!=
like
startwith
endwith
, !like
Sort output by a column.
http://localhost:8001/tests?sortby=id;asc
http://localhost:8001/tests?sortby=id;desc
http://localhost:8001/tests?title=Pro&sortby=id&is_active=false
[
{
"id": "49",
"title": "Prof. Delphine Cremin",
"is_active": false,
"number_integer": 7,
"number_double": 0,
"created_at": "2016-01-23 15:21:19",
"updated_at": "2016-01-23 15:21:19"
},
{
"id": "4",
"title": "Prof. Beryl Daugherty",
"is_active": false,
"number_integer": 9,
"number_double": 174.430750667,
"created_at": "2016-01-23 15:21:19",
"updated_at": "2016-01-23 15:21:19"
}
]
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email it@talk-point.de instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.