<?php
namespace App\Actions\User;
use App\Lib\Slime\RestAction\ApiAction;
use App\Lib\Slime\RestAction\Traits\Pagination;
use App\Models\Users\User;
class UserGetAll extends ApiAction
{
use Pagination;
protected function performAction()
{
$this->pagination = $this->getPaginationParams($this->request);
$this->payload = User::filter(
$this->getQueryParams()
)->page(
$this->pagination
)->get();
}
}
<?php
namespace App\Models\Users;
use App\Lib\Slime\Models\SlimeModel;
class User extends SlimeModel
{
/**
* @var array
*/
protected $fillable = [
'name',
'surname',
'email',
'age',
];
protected $filters = [
'name' => [
'col' => 'name',
'op' => 'LIKE'
]
];
}
{
"code": 200,
"message": "OK",
"payload": [
{
"id": 1,
"name": "Sherman Balistreri",
"username": "israel40",
"email": "[email protected]"
},
{
"id": 2,
"name": "Mrs. Coralie Grady",
"username": "rempel.meta",
"email": "[email protected]"
}
],
"pagination": {
"page": 1,
"limit": 20
}
}