Commit efa4906c authored by Viral Solani's avatar Viral Solani

Misc changes in APIs

parent 23b20325
...@@ -10,6 +10,7 @@ use Illuminate\Session\TokenMismatchException; ...@@ -10,6 +10,7 @@ use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
...@@ -75,12 +76,12 @@ class Handler extends ExceptionHandler ...@@ -75,12 +76,12 @@ class Handler extends ExceptionHandler
return $this->setStatusCode(422)->respondWithError($exception->validator->messages()); return $this->setStatusCode(422)->respondWithError($exception->validator->messages());
} }
}
/* /*
* Redirect if token mismatch error * Redirect if token mismatch error
* Usually because user stayed on the same screen too long and their session expired * Usually because user stayed on the same screen too long and their session expired
*/ */
if ($exception instanceof \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException) { if ($exception instanceof UnauthorizedHttpException) {
switch (get_class($exception->getPrevious())) { switch (get_class($exception->getPrevious())) {
case \App\Exceptions\Handler::class: case \App\Exceptions\Handler::class:
return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token has not been provided.'); return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token has not been provided.');
...@@ -91,6 +92,7 @@ class Handler extends ExceptionHandler ...@@ -91,6 +92,7 @@ class Handler extends ExceptionHandler
return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token is invalid.'); return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token is invalid.');
} }
} }
}
/* /*
* Redirect if token mismatch error * Redirect if token mismatch error
......
...@@ -21,6 +21,7 @@ class RoleResource extends Resource ...@@ -21,6 +21,7 @@ class RoleResource extends Resource
'permission' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'), 'permission' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'),
'noofuses' => $this->users->count(), 'noofuses' => $this->users->count(),
'sort' => $this->sort, 'sort' => $this->sort,
'status' => $this->status
]; ];
} }
} }
...@@ -49,6 +49,7 @@ class RoleRepository extends BaseRepository ...@@ -49,6 +49,7 @@ class RoleRepository extends BaseRepository
config('access.roles_table').'.name', config('access.roles_table').'.name',
config('access.roles_table').'.all', config('access.roles_table').'.all',
config('access.roles_table').'.sort', config('access.roles_table').'.sort',
config('access.roles_table').'.status',
DB::raw("GROUP_CONCAT( DISTINCT permissions.display_name SEPARATOR '<br/>') as permission_name"), DB::raw("GROUP_CONCAT( DISTINCT permissions.display_name SEPARATOR '<br/>') as permission_name"),
DB::raw('(SELECT COUNT(role_user.id) FROM role_user LEFT JOIN users ON role_user.user_id = users.id WHERE role_user.role_id = roles.id AND users.deleted_at IS NULL) AS userCount'), DB::raw('(SELECT COUNT(role_user.id) FROM role_user LEFT JOIN users ON role_user.user_id = users.id WHERE role_user.role_id = roles.id AND users.deleted_at IS NULL) AS userCount'),
]) ])
......
...@@ -36,6 +36,8 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio ...@@ -36,6 +36,8 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
// Roles // Roles
Route::resource('roles', 'RolesController', ['except' => ['create', 'edit']]); Route::resource('roles', 'RolesController', ['except' => ['create', 'edit']]);
Route::post('roles/delete-all', 'RolesController@deleteAll');
// Permission // Permission
Route::resource('permission', 'PermissionController', ['except' => ['create', 'edit']]); Route::resource('permission', 'PermissionController', ['except' => ['create', 'edit']]);
......
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