CrudContract
Table of Contents
Methods
- _checkPaginationInternal() : bool
- Detects if we have pagination params anywhere in the request.
- allItems() : array<string|int, mixed>|null
- Retrieve all in CRUD
- checkIfFieldPassesAllValidations() : mixed
- createItem() : object|null
- Create in CRUD Saves in transactions, runs pre and post create events
- deleteItem() : mixed
- Delete in CRUD Handles both post and pre delete events Deletes in joined mode if defined too, but will delete only from the main table
- detectPagination() : bool
- Detect if our pagination params are defined anywhere in the request.
- getAllWithPagination() : array<string|int, mixed>|null
- Retrieve all with pagination
- getOne() : object|null
- Retrieve in CRUD, returns on Item at a time.
- hasLimit() : mixed
- hasOffset() : mixed
- isInJoinMode() : bool
- paginate() : array<string|int, mixed>|null
- randomItem() : mixed
- updateItem() : object|array<string|int, mixed>|null
- Updated an item in the db.
- cleanRelationColumns() : void
- If the fields are already in the format of relationships, this method reverses that including removing duplicates.
- detectAndAddColumns() : void
- Checks if the frontend has defined columns we should query by.
- getListColumns() : array<string|int, mixed>|string
- Returns the columns we shall query from the db while querying
- getOneInternal() : null|array<string|int, mixed>|object
- Gets one item from the database. Can be overridden by defining a getOne method in the service
- primaryKey() : bool|string
- Returns the primary key field
Methods
_checkPaginationInternal()
Detects if we have pagination params anywhere in the request.
protected
_checkPaginationInternal(array<string|int, mixed> $data) : bool
For pagination to kick-in, both offset and limit must be defined at any of the levels
defined by $this->detectPagination()
Parameters
- $data : array<string|int, mixed>
Tags
Return values
boolallItems()
Retrieve all in CRUD
protected
allItems() : array<string|int, mixed>|null
Can be overridden by defining a getItems method in the service
Tags
Return values
array<string|int, mixed>|nullcheckIfFieldPassesAllValidations()
protected
checkIfFieldPassesAllValidations(mixed $field) : mixed
Parameters
- $field : mixed
Tags
createItem()
Create in CRUD Saves in transactions, runs pre and post create events
protected
createItem() : object|null
Tags
Return values
object|nulldeleteItem()
Delete in CRUD Handles both post and pre delete events Deletes in joined mode if defined too, but will delete only from the main table
protected
deleteItem() : mixed
Tags
detectPagination()
Detect if our pagination params are defined anywhere in the request.
protected
detectPagination(array<string|int, mixed> $reqData) : bool
Remember these can in defined in one of the following:-
On the request root level
Parameters
- $reqData : array<string|int, mixed>
Tags
Return values
boolgetAllWithPagination()
Retrieve all with pagination
protected
getAllWithPagination() : array<string|int, mixed>|null
Tags
Return values
array<string|int, mixed>|nullgetOne()
Retrieve in CRUD, returns on Item at a time.
protected
getOne() : object|null
Tags
Return values
object|nullhasLimit()
protected
hasLimit() : mixed
hasOffset()
protected
hasOffset() : mixed
isInJoinMode()
protected
isInJoinMode() : bool
Return values
boolpaginate()
protected
paginate() : array<string|int, mixed>|null
Tags
Return values
array<string|int, mixed>|nullrandomItem()
protected
randomItem() : mixed
Tags
updateItem()
Updated an item in the db.
protected
updateItem() : object|array<string|int, mixed>|null
If updateColumns are defined, it only updates those.
It also calls both preUpdate and postUpdate hooks if defined
Tags
Return values
object|array<string|int, mixed>|nullcleanRelationColumns()
If the fields are already in the format of relationships, this method reverses that including removing duplicates.
private
cleanRelationColumns() : void
Tags
detectAndAddColumns()
Checks if the frontend has defined columns we should query by.
private
detectAndAddColumns() : void
Works for both joined and non-joined querying. It pays respect to aliases defined, so, don't forget to respect them too!
getListColumns()
Returns the columns we shall query from the db while querying
private
getListColumns() : array<string|int, mixed>|string
Return values
array<string|int, mixed>|stringgetOneInternal()
Gets one item from the database. Can be overridden by defining a getOne method in the service
private
getOneInternal(mixed $id) : null|array<string|int, mixed>|object
Parameters
- $id : mixed
Tags
Return values
null|array<string|int, mixed>|objectprimaryKey()
Returns the primary key field
private
primaryKey() : bool|string