Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
41983ea1
Unverified
Commit
41983ea1
authored
Mar 13, 2018
by
Viral Solani
Committed by
GitHub
Mar 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #169 from viralsolani/analysis-XplWZW
Apply fixes from StyleCI
parents
78a91df2
a30d7ba8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
26 additions
and
42 deletions
+26
-42
Handler.php
app/Exceptions/Handler.php
+11
-12
APIController.php
app/Http/Controllers/Api/V1/APIController.php
+2
-3
BlogTagsController.php
app/Http/Controllers/Api/V1/BlogTagsController.php
+3
-6
DeactivatedUsersController.php
app/Http/Controllers/Api/V1/DeactivatedUsersController.php
+1
-4
DeletedUsersController.php
app/Http/Controllers/Api/V1/DeletedUsersController.php
+1
-5
RolesController.php
app/Http/Controllers/Api/V1/RolesController.php
+5
-7
UsersController.php
app/Http/Controllers/Api/V1/UsersController.php
+1
-1
StoreApiBlogTagsRequest.php
...ttp/Requests/Backend/BlogTags/StoreApiBlogTagsRequest.php
+0
-1
api.php
routes/api.php
+2
-3
No files found.
app/Exceptions/Handler.php
View file @
41983ea1
...
@@ -51,30 +51,30 @@ class Handler extends ExceptionHandler
...
@@ -51,30 +51,30 @@ class Handler extends ExceptionHandler
*/
*/
public
function
render
(
$request
,
Exception
$exception
)
public
function
render
(
$request
,
Exception
$exception
)
{
{
/*
/*
* 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
\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
)
{
switch
(
get_class
(
$exception
->
getPrevious
()))
{
switch
(
get_class
(
$exception
->
getPrevious
()))
{
case
\App\Exceptions\Handler
::
class
:
case
\App\Exceptions\Handler
::
class
:
return
response
()
->
json
([
return
response
()
->
json
([
'status'
=>
'error'
,
'status'
=>
'error'
,
'error'
=>
'Token has not been provided'
,
'error'
=>
'Token has not been provided'
,
'data'
=>
json_decode
(
"{}"
),
'data'
=>
json_decode
(
'{}'
),
],
$exception
->
getStatusCode
());
],
$exception
->
getStatusCode
());
case
\Tymon\JWTAuth\Exceptions\TokenExpiredException
::
class
:
case
\Tymon\JWTAuth\Exceptions\TokenExpiredException
::
class
:
return
response
()
->
json
([
return
response
()
->
json
([
'status'
=>
'error'
,
'status'
=>
'error'
,
'error'
=>
'Token has expired'
,
'error'
=>
'Token has expired'
,
'data'
=>
json_decode
(
"{}"
),
'data'
=>
json_decode
(
'{}'
),
],
$exception
->
getStatusCode
());
],
$exception
->
getStatusCode
());
case
\Tymon\JWTAuth\Exceptions\TokenInvalidException
::
class
:
case
\Tymon\JWTAuth\Exceptions\TokenInvalidException
::
class
:
case
\Tymon\JWTAuth\Exceptions\TokenBlacklistedException
::
class
:
case
\Tymon\JWTAuth\Exceptions\TokenBlacklistedException
::
class
:
return
response
()
->
json
([
return
response
()
->
json
([
'status'
=>
'error'
,
'status'
=>
'error'
,
'error'
=>
'Token is invalid'
,
'error'
=>
'Token is invalid'
,
'data'
=>
json_decode
(
"{}"
),
'data'
=>
json_decode
(
'{}'
),
],
$exception
->
getStatusCode
());
],
$exception
->
getStatusCode
());
default
:
default
:
break
;
break
;
...
@@ -93,8 +93,8 @@ class Handler extends ExceptionHandler
...
@@ -93,8 +93,8 @@ class Handler extends ExceptionHandler
*/
*/
if
(
$exception
instanceof
GeneralException
)
{
if
(
$exception
instanceof
GeneralException
)
{
//Note:Below code is required when we use an extra class as api request then we need to pass accept:application/json in the header also
//Note:Below code is required when we use an extra class as api request then we need to pass accept:application/json in the header also
//if the header has accept application/json then $request->wantsJson() returns true
//if the header has accept application/json then $request->wantsJson() returns true
// if ($request->ajax() || $request->wantsJson()){
// if ($request->ajax() || $request->wantsJson()){
// $json = [
// $json = [
// 'success' => false,
// 'success' => false,
// 'error' => [
// 'error' => [
...
@@ -145,7 +145,6 @@ class Handler extends ExceptionHandler
...
@@ -145,7 +145,6 @@ class Handler extends ExceptionHandler
*/
*/
protected
function
unauthenticated
(
$request
,
AuthenticationException
$exception
)
protected
function
unauthenticated
(
$request
,
AuthenticationException
$exception
)
{
{
if
(
$request
->
expectsJson
())
{
if
(
$request
->
expectsJson
())
{
return
response
()
->
json
([
'error'
=>
'Unauthenticated.'
],
401
);
return
response
()
->
json
([
'error'
=>
'Unauthenticated.'
],
401
);
}
}
...
...
app/Http/Controllers/Api/V1/APIController.php
View file @
41983ea1
...
@@ -178,8 +178,7 @@ class APIController extends Controller
...
@@ -178,8 +178,7 @@ class APIController extends Controller
return
$this
->
setStatusCode
(
204
)
->
respond
(
null
);
return
$this
->
setStatusCode
(
204
)
->
respond
(
null
);
}
}
/**Note this function is same as the below function but instead of responding with error below function returns error json
/**Note this function is same as the below function but instead of responding with error below function returns error json
* Throw Validation.
* Throw Validation.
*
*
* @param string $message
* @param string $message
...
@@ -201,6 +200,6 @@ class APIController extends Controller
...
@@ -201,6 +200,6 @@ class APIController extends Controller
*/
*/
public
function
throwValidation
(
$validation
)
public
function
throwValidation
(
$validation
)
{
{
return
[
"error"
=>
$validation
->
errors
()];
return
[
'error'
=>
$validation
->
errors
()];
}
}
}
}
app/Http/Controllers/Api/V1/BlogTagsController.php
View file @
41983ea1
...
@@ -2,13 +2,12 @@
...
@@ -2,13 +2,12 @@
namespace
App\Http\Controllers\Api\V1
;
namespace
App\Http\Controllers\Api\V1
;
use
App\Http\Requests\Backend\BlogTags\StoreApiBlogTagsRequest
;
use
App\Http\Resources\BlogTagsResource
;
use
App\Http\Resources\BlogTagsResource
;
use
App\Models\BlogTags\BlogTag
;
use
App\Models\BlogTags\BlogTag
;
use
App\Repositories\Backend\BlogTags\BlogTagsRepository
;
use
App\Repositories\Backend\BlogTags\BlogTagsRepository
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
App\Http\Requests\Backend\BlogTags\StoreApiBlogTagsRequest
;
use
Validator
;
use
Validator
;
use
Exception
;
class
BlogTagsController
extends
APIController
class
BlogTagsController
extends
APIController
{
{
...
@@ -68,15 +67,13 @@ class BlogTagsController extends APIController
...
@@ -68,15 +67,13 @@ class BlogTagsController extends APIController
return
new
BlogTagsResource
(
BlogTag
::
orderBy
(
'created_at'
,
'desc'
)
->
first
());
return
new
BlogTagsResource
(
BlogTag
::
orderBy
(
'created_at'
,
'desc'
)
->
first
());
}
}
/** NOTE This function is same as about but uses StoreApiBlogTagsRequest for validation of the api
/** NOTE This function is same as about but uses StoreApiBlogTagsRequest for validation of the api
* Creates the Resource for BlogTag.
* Creates the Resource for BlogTag.
*
*
* @param Request $request
* @param Request $request
*
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*
*
*/
*/
// public function store(StoreApiBlogTagsRequest $request)
// public function store(StoreApiBlogTagsRequest $request)
// {
// {
...
...
app/Http/Controllers/Api/V1/DeactivatedUsersController.php
View file @
41983ea1
...
@@ -2,17 +2,14 @@
...
@@ -2,17 +2,14 @@
namespace
App\Http\Controllers\Api\V1
;
namespace
App\Http\Controllers\Api\V1
;
use
App\Events\Backend\Access\User\UserCreated
;
use
App\Events\Backend\Access\User\UserUpdated
;
use
App\Http\Resources\UserResource
;
use
App\Http\Resources\UserResource
;
use
App\Models\Access\User\User
;
use
App\Repositories\Backend\Access\User\UserRepository
;
use
App\Repositories\Backend\Access\User\UserRepository
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Validator
;
class
DeactivatedUsersController
extends
APIController
class
DeactivatedUsersController
extends
APIController
{
{
protected
$repository
;
protected
$repository
;
/**
/**
* __construct.
* __construct.
*
*
...
...
app/Http/Controllers/Api/V1/DeletedUsersController.php
View file @
41983ea1
...
@@ -2,17 +2,14 @@
...
@@ -2,17 +2,14 @@
namespace
App\Http\Controllers\Api\V1
;
namespace
App\Http\Controllers\Api\V1
;
use
App\Events\Backend\Access\User\UserCreated
;
use
App\Events\Backend\Access\User\UserUpdated
;
use
App\Http\Resources\UserResource
;
use
App\Http\Resources\UserResource
;
use
App\Models\Access\User\User
;
use
App\Repositories\Backend\Access\User\UserRepository
;
use
App\Repositories\Backend\Access\User\UserRepository
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Validator
;
class
DeletedUsersController
extends
APIController
class
DeletedUsersController
extends
APIController
{
{
protected
$repository
;
protected
$repository
;
/**
/**
* __construct.
* __construct.
*
*
...
@@ -38,5 +35,4 @@ class DeletedUsersController extends APIController
...
@@ -38,5 +35,4 @@ class DeletedUsersController extends APIController
$this
->
repository
->
getForDataTable
(
0
,
true
)
->
paginate
(
$limit
)
$this
->
repository
->
getForDataTable
(
0
,
true
)
->
paginate
(
$limit
)
);
);
}
}
}
}
app/Http/Controllers/Api/V1/RolesController.php
View file @
41983ea1
...
@@ -22,7 +22,6 @@ class RolesController extends APIController
...
@@ -22,7 +22,6 @@ class RolesController extends APIController
$this
->
repository
=
$repository
;
$this
->
repository
=
$repository
;
}
}
/**
/**
* Return the roles.
* Return the roles.
*
*
...
@@ -94,8 +93,8 @@ class RolesController extends APIController
...
@@ -94,8 +93,8 @@ class RolesController extends APIController
}
}
/**
/**
* @param Role
$role
* @param Role $role
* @param Request
$request
* @param Request $request
*
*
* @return \Illuminate\Http\JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
*/
...
@@ -112,10 +111,9 @@ class RolesController extends APIController
...
@@ -112,10 +111,9 @@ class RolesController extends APIController
* validateUser User.
* validateUser User.
*
*
* @param $request
* @param $request
*
*
* @return Validator object
* @return Validator object
*/
*/
public
function
validateRole
(
Request
$request
)
public
function
validateRole
(
Request
$request
)
{
{
$permissions
=
''
;
$permissions
=
''
;
...
@@ -125,7 +123,7 @@ class RolesController extends APIController
...
@@ -125,7 +123,7 @@ class RolesController extends APIController
}
}
$validation
=
Validator
::
make
(
$request
->
all
(),
[
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'name'
=>
'required|max:191'
,
'name'
=>
'required|max:191'
,
'permissions'
=>
$permissions
,
'permissions'
=>
$permissions
,
]);
]);
...
...
app/Http/Controllers/Api/V1/UsersController.php
View file @
41983ea1
...
@@ -76,7 +76,7 @@ class UsersController extends APIController
...
@@ -76,7 +76,7 @@ class UsersController extends APIController
* @param Request $request
* @param Request $request
* @param User $user
* @param User $user
*
*
* @return Validator object
* @return Validator object
*/
*/
public
function
update
(
Request
$request
,
User
$user
)
public
function
update
(
Request
$request
,
User
$user
)
{
{
...
...
app/Http/Requests/Backend/BlogTags/StoreApiBlogTagsRequest.php
View file @
41983ea1
...
@@ -26,7 +26,6 @@ class StoreApiBlogTagsRequest extends Request
...
@@ -26,7 +26,6 @@ class StoreApiBlogTagsRequest extends Request
*/
*/
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
'name'
=>
'required|max:191'
,
'name'
=>
'required|max:191'
,
];
];
...
...
routes/api.php
View file @
41983ea1
...
@@ -28,13 +28,12 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
...
@@ -28,13 +28,12 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
// Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset');
// Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset');
});
});
// Users
// Users
Route
::
resource
(
'users'
,
'UsersController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
Route
::
resource
(
'users'
,
'UsersController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
Route
::
get
(
'deactivatedUsers'
,
'DeactivatedUsersController@index'
);
Route
::
get
(
'deactivatedUsers'
,
'DeactivatedUsersController@index'
);
Route
::
get
(
'deletedUsers'
,
'DeletedUsersController@index'
);
Route
::
get
(
'deletedUsers'
,
'DeletedUsersController@index'
);
// Roles
// Roles
Route
::
resource
(
'roles'
,
'RolesController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
Route
::
resource
(
'roles'
,
'RolesController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
// Permission
// Permission
Route
::
resource
(
'permission'
,
'PermissionController'
);
Route
::
resource
(
'permission'
,
'PermissionController'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment