Commit 9a527ae4 authored by Viral Solani's avatar Viral Solani

API changes in user , role and permission

parent 89a4ef1f
......@@ -31,10 +31,12 @@ class PermissionController extends APIController
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return PermissionResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy,$orderBy)->paginate($limit)
);
}
......
......@@ -31,10 +31,12 @@ class RolesController extends APIController
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return RoleResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy,$orderBy)->paginate($limit)
);
}
......@@ -60,6 +62,7 @@ class RolesController extends APIController
public function store(Request $request)
{
$validation = $this->validateRole($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
......
......@@ -31,10 +31,12 @@ class UsersController extends APIController
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return UserResource::collection(
$this->repository->getForDataTable(1, false)->paginate($limit)
$this->repository->getForDataTable(1, false)->orderBy($sortBy,$orderBy)->paginate($limit)
);
}
......
......@@ -25,8 +25,8 @@ class UserResource extends Resource
'role' => optional($this->roles()->first())->name,
'permissions' => $this->permissions()->get(),
'status' => $this->status,
'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(),
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment