-
Notifications
You must be signed in to change notification settings - Fork 0
4. Request
You can safely select the model from the database with their corresponding field name, example
?name=DimasSatrio
To find the data with the exact name.
?name=$Dimas
To find the data with name Like %Dimas% operator
?age>5
To find the data with age more than 5
?age<5
To find the data with age less than 5
?age=1,3,4,5
To find the data with age 1, 3, 4, 5 (you could use id as parameter too!)
?age=!5 To find all the data that is not aged 5
To paginate your returned data, you could use special request key limit and page, don't forget you couldn't use limit and page as your field name (Might change in the future)
?limit=10&page=5
"meta": {
"pagination": {
"total": 119,
"count": 10,
"per_page": 10,
"current_page": 5,
"total_pages": 12,
"links": {
"previous": "http://ramencore.dev/users?page=4",
"next": "http://ramencore.dev/users?page=6"
}
}
}
You could also order the result with special request key orderBy
?limit=10&page=5&orderBy=>name
Order By name Ascending
?limit=10&page=5&orderBy=>name,<id
Order By name Ascending, and then id Descending
RamenRest allow you to add relation of your model via request relation. This relation need to be setup first on your transformer files that extend from League\Fractal\TransformerAbstract. And then your model need to reference this transformer via getTransformer method.
public function getTransformer(){
return $this->transformer; // Which need to be instantiated from League\Fractal\TransformerAbstract
}
You could easily get all the entity that have been soft deleted via query parameter soft=true
?soft=true
By adding $files array inside the model, and then reference it with getFiles() function. You could trigger, the upload files mechanism on the listed parameter. Be advised that this option is able to upload multiple files by referencing it as attributes[] parameter on the request body.
protected $files = [
"avatar"
];
public function getFiles()
{
return $this->files;
}