VERSION FRAMEWORK : 10.X
example Laravel Rest Api, progress build...
PHP : 8.1 - 8.3
.
+-- app
| +-- Exceptions
| | +-- Handler.php
Using Filter Query
use Saidqb\LaravelSupport\SQ;
$query = SQ::make('QueryFilter')
->request($request->all())
->select([
'id',
'name as full_name',
'email',
])
->search([
'name',
'email',
])
->query(function(){
return DB::table('users');
});
return $this->response($query->get());
Response modifier
SQ::responseConfig([
'hide' => ['password'],
'decode' => [],
'decode_array' => [],
]);
HEADER
#Akses Api
Api-Key: <yor api key>
# Akses data login, token didapat dari login
Authorization: Bearer <token>
display single data
{
"status": 200,
"success": true,
"error_code": 0,
"message": "success",
"data": {
"item": {}
}
}
display multiple data
{
"status": 200,
"success": true,
"error_code": 0,
"message": "success",
"data": {
"items": [],
"pagination" : {}
}
}
Key | Name | Result |
---|---|---|
eq |
equal | field = 'value' |
neq |
not equal | field != 'value' |
lt |
lower than | field < 'value' |
gt |
greater than | field > 'value' |
lte |
lower than equal | field <= 'value' |
gte |
greater than equal | field >= 'value' |
le |
like end | field LIKE 'value%' |
ls |
like start | field LIKE '%value' |
lse |
like start end | field LIKE '%value%' |
in |
where IN | field IN (value) value using sparator , ex 1,2,3,4 / 1 |
nin |
where NOT IN | field NOT IN (value) value using sparator , ex 1,2,3,4 / 1 |
- Sort =>
sort=-user_name
=>SORT user_name DESC
- Sort =>
sort=user_name
=>SORT user_name ASC
- Sort => field sort sesuai dengan result
- limit => default: 10
- page => default: 1
- search =>
search=keyword
COFFEE HERE for more inovation
OR