CRUD [ Create Read Update Delete ]
list_type
->string[pagination,collection] default paginationcolumns
->string default all columns. separated from each other by a comma(,)- host.com/products?columns=id,name,description,... add more with
,
- host.com/products?columns=id,name,description,... add more with
relations
->string default null- multi relations=parent;author;... add more with
;
- And you can multi relationship with dot notation relations=products.mainImage;author;...
- multi relations=parent;author;... add more with
limit
->integer default 30- working with colection
per_page
->integer default 30- working with pagination
conditions
->string|array default null- the conditions are and with each other
- string condition=column:value;column2:value2
- array condition[column]=value&column[column2]=value2
or you can use this on one variable
https://host.com/users?conditions[first_name]=Jahongir&conditions[last_name]=Jahongir&conditions[author.middle_name]=Jahongir
https://host.com/users?condition=first_name:Jahongir;last_name:Tursunboyev;author.middle_name=doe
not_conditions
-> array default null- conditions and with each other. and the result will be reversed
- not_conditions reverse conditions
or_conditions
-> array default null- the conditions are or with each other
- or_conditions from request, if any of them are equal it will work
between
->array default null- array accessive key=column value=int or date between FROMtoTO,if only FROM is given, it is taken from FROM to the end. if only TO(toTO) is given, it takes from start to TO . if between(FROMtoTO) is given, it takes all the data inside FROMtoTO
- {{host}}/users?between[price]=100to200&between[created_at]=2022-11-10&between[amount]=to200
not_between
->not_between reverse betweenis_active
->boolean[or 0,1] default all- or
conditions[is_active]=0
[0,1]\
- or
search
->string default nullsearchFilds
->string array default null.- string
https://host.com/users?search=John&searchFilds=first_name,last_name,author.first_name
- array
https://host.com/users?search=John&searchFields[]=first_name&searchFields[]=last_name&searchFields[]=author.first_name
orderBy
->string default idsortBy
-> string[asc,desc] default descappends
->string default null- working with collection
- multi appends=full_name;appends2;... add more with
;
pluck
->string default null- The pluck method retrieves all of the values for a given key:
- https://host.com/products?list_type=collection
{ "products": [ { "id": 150, "category_id": 5, "name": "suscipit" }, { "id": 149, "category_id": 11, "name": "aspernatur" }, { "id": 148, "category_id": 5, "name": "occaecati" } ] }
- https://host.com/products?list_type=collection&pluck=name
{ "products": [ "suscipit", "aspernatur", "occaecati", "iure" ] }
- working with collection
- The pluck method also supports retrieving nested values using "dot" notation
- https://host.com/products?relations=category.author&list_type=collection&pluck=id:category.author.first_name
{ "products": [ "150": "Isaias", "149": "Rubye", "148": "Rubye", "147": "Urban", "146": "Caden", "145": "Alexandre", "144": "Super", "143": "Emerald", "142": "Jamison" ] }
- note : object keys unique
only_deleted
->boolean[0,1] default 0(false)
Sort, OrderBy
host.com/directory?orderBy=column
https://host.com/products?orderBy=name&sortBy=ASC
[
{
"id": 3,
"category_id": 3,
"name": "Apple"
},
{
"id": 1,
"name": "Grape"
},
{
"id": 2,
"name": "Kiwi"
}
]
Sorting through relation's column only works with belongsTo relation.Does not work multi-depth dot notation.Only works with one dot(one relation)
host.com/directory?orderBy=relation.column
https://host.com/products?orderBy=category.name&sortedBy=desc
Query will have something like this
...
LEFT JOIN categories ON products.category_id = categories.id
...
ORDER BY categories.name
...
Multi orderBy
host.com/directory?orderBy=column;relation.column;relation2.column2...
https://host.com/products?orderBy=name;category.name&sortedBy=desc
Product::leftJoin("categories", "products.category_id", "categories.id")->orderBy('name','desc')->orderBy('categories.name','desc');
...
Model::leftJoin("relationTable", "selfTable.foreignKey", "relationTable.ownerKey")->orderBy('column')->orderBy('relationTable.column')...;
Accept-Language
:ru [ru,uz,en] default ruAccept
:application/jsonrequired
{
"code": 200,
"message": "OK",
"data": {
//data
}
}
{
"code": 422,
"message": "The given data was invalid.",
"data": {
"errors": {
//Errors
}
}
}
code
->int [200,201,204,401,403,404,422,500]message
->string default ''- the language of the message will be changed by the header Accept-Language
data
->array|Collection default []
Example
- Profile RU
- User CRUD --- set role
- Category CRUD
- Role CRUD //todo
- Product CRUD //todo