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
0ab5fbf3
Unverified
Commit
0ab5fbf3
authored
Mar 08, 2018
by
Viral Solani
Committed by
GitHub
Mar 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #152 from viralsolani/analysis-q5QYVB
Apply fixes from StyleCI
parents
438851c2
5911cfa9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
46 deletions
+42
-46
PermissionController.php
app/Http/Controllers/Api/V1/PermissionController.php
+7
-8
RolesController.php
app/Http/Controllers/Api/V1/RolesController.php
+6
-9
UsersController.php
app/Http/Controllers/Api/V1/UsersController.php
+18
-17
RoleResource.php
app/Http/Resources/RoleResource.php
+3
-3
UserResource.php
app/Http/Resources/UserResource.php
+8
-9
No files found.
app/Http/Controllers/Api/V1/PermissionController.php
View file @
0ab5fbf3
...
...
@@ -8,7 +8,6 @@ use App\Repositories\Backend\Access\Permission\PermissionRepository;
use
Illuminate\Http\Request
;
use
Validator
;
class
PermissionController
extends
APIController
{
protected
$repository
;
...
...
@@ -50,7 +49,7 @@ class PermissionController extends APIController
}
/**
* Creates the Resourse for Role
* Creates the Resourse for Role
.
*
* @param Request $request
*
...
...
@@ -65,10 +64,10 @@ class PermissionController extends APIController
$this
->
repository
->
create
(
$request
->
all
());
$permission
=
Permission
::
orderBy
(
'created_at'
,
'desc'
)
->
first
();
return
new
PermissionResource
(
$permission
);
}
/**
* @param Role $role
* @param UpdateRoleRequest $request
...
...
@@ -77,7 +76,6 @@ class PermissionController extends APIController
*/
public
function
update
(
Request
$request
,
Permission
$permission
)
{
$validation
=
$this
->
valiatingRequest
(
$request
);
if
(
$validation
->
fails
())
{
...
...
@@ -93,13 +91,14 @@ class PermissionController extends APIController
public
function
valiatingRequest
(
Request
$request
)
{
$validation
=
Validator
::
make
(
$request
->
all
(),[
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'name'
=>
'required|max:191'
,
'display_name'
=>
'required|max:191'
,
]);
return
$validation
;
}
/**
* @param Role $role
* @param DeleteRoleRequest $request
...
...
@@ -110,6 +109,6 @@ class PermissionController extends APIController
{
$this
->
repository
->
delete
(
$permission
);
return
[
"message"
=>
"success"
];
return
[
'message'
=>
'success'
];
}
}
app/Http/Controllers/Api/V1/RolesController.php
View file @
0ab5fbf3
...
...
@@ -8,7 +8,6 @@ use App\Repositories\Backend\Access\Role\RoleRepository;
use
Illuminate\Http\Request
;
use
Validator
;
class
RolesController
extends
APIController
{
protected
$repository
;
...
...
@@ -50,7 +49,7 @@ class RolesController extends APIController
}
/**
* Creates the Resourse for Role
* Creates the Resourse for Role
.
*
* @param Request $request
*
...
...
@@ -65,11 +64,9 @@ class RolesController extends APIController
$this
->
repository
->
create
(
$request
->
all
());
return
new
RoleResource
(
Role
::
orderBy
(
'created_at'
,
'desc'
)
->
first
());
}
/**
* @param Role $role
* @param UpdateRoleRequest $request
...
...
@@ -78,7 +75,6 @@ class RolesController extends APIController
*/
public
function
update
(
Request
$request
,
Role
$role
)
{
$validation
=
$this
->
valiatingRequest
(
$request
);
if
(
$validation
->
fails
())
{
...
...
@@ -87,7 +83,7 @@ class RolesController extends APIController
$this
->
repository
->
update
(
$role
,
$request
->
all
());
$role
=
Role
::
findOrfail
(
$role
->
id
);
$role
=
Role
::
findOrfail
(
$role
->
id
);
return
new
RoleResource
(
$role
);
}
...
...
@@ -96,7 +92,7 @@ class RolesController extends APIController
{
$permissions
=
''
;
if
(
$request
->
post
(
"associated_permissions"
)
!=
'all'
)
{
if
(
$request
->
post
(
'associated_permissions'
)
!=
'all'
)
{
$permissions
=
'required'
;
}
...
...
@@ -107,6 +103,7 @@ class RolesController extends APIController
return
$validation
;
}
/**
* @param Role $role
* @param DeleteRoleRequest $request
...
...
@@ -117,6 +114,6 @@ class RolesController extends APIController
{
$this
->
repository
->
delete
(
$role
);
return
[
"message"
=>
"success"
];
return
[
'message'
=>
'success'
];
}
}
app/Http/Controllers/Api/V1/UsersController.php
View file @
0ab5fbf3
...
...
@@ -6,7 +6,6 @@ use App\Http\Resources\UserResource;
use
App\Models\Access\User\User
;
use
App\Repositories\Backend\Access\User\UserRepository
;
use
Illuminate\Http\Request
;
use
Illuminate\Validation\Rule
;
use
Validator
;
class
UsersController
extends
APIController
...
...
@@ -47,20 +46,19 @@ class UsersController extends APIController
public
function
show
(
User
$user
)
{
$data
=
new
UserResource
(
$user
);
$history
[
"history"
]
=
history
()
->
renderEntity
(
'User'
,
$user
->
id
);
$history
[
'history'
]
=
history
()
->
renderEntity
(
'User'
,
$user
->
id
);
$maindata
=
$data
->
toArray
(
$user
);
$maindata
=
array_merge
(
$maindata
,
$history
);
return
$maindata
;
}
/**
* Update the specified resource in storage.
*/
public
function
update
(
Request
$request
,
User
$user
)
{
$validation
=
$this
->
valiatingRequest
(
$request
,
"edit"
,
$user
->
id
);
$validation
=
$this
->
valiatingRequest
(
$request
,
'edit'
,
$user
->
id
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
...
@@ -84,14 +82,16 @@ class UsersController extends APIController
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$this
->
repository
->
create
(
$request
);
return
new
UserResource
(
User
::
orderBy
(
'created_at'
,
'desc'
)
->
first
());
}
/**
* Validation function to validate user input
* Validation function to validate user input
.
*/
public
function
valiatingRequest
(
Request
$request
,
$string
=
""
,
$id
=
0
)
public
function
valiatingRequest
(
Request
$request
,
$string
=
''
,
$id
=
0
)
{
$password
=
(
$string
==
"edit"
)
?
""
:
"required|min:6|confirmed"
;
$password
=
(
$string
==
'edit'
)
?
''
:
'required|min:6|confirmed'
;
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'first_name'
=>
'required|max:255'
,
'last_name'
=>
'required|max:255'
,
...
...
@@ -105,7 +105,8 @@ class UsersController extends APIController
}
/**
* Api to delete the resource
* Api to delete the resource.
*
* @param Role $role
* @param DeleteRoleRequest $request
*
...
...
@@ -115,6 +116,6 @@ class UsersController extends APIController
{
$this
->
repository
->
delete
(
$user
);
return
[
"message"
=>
"success"
];
return
[
'message'
=>
'success'
];
}
}
app/Http/Resources/RoleResource.php
View file @
0ab5fbf3
...
...
@@ -18,9 +18,9 @@ class RoleResource extends Resource
return
[
'id'
=>
$this
->
id
,
'name'
=>
$this
->
name
,
"permission"
=>
(
$this
->
all
)
?
"All"
:
optional
(
$this
->
permissions
)
->
pluck
(
"display_name"
),
"noofuses"
=>
$this
->
users
->
count
(),
"sort"
=>
$this
->
sort
,
'permission'
=>
(
$this
->
all
)
?
'All'
:
optional
(
$this
->
permissions
)
->
pluck
(
'display_name'
),
'noofuses'
=>
$this
->
users
->
count
(),
'sort'
=>
$this
->
sort
,
];
}
}
app/Http/Resources/UserResource.php
View file @
0ab5fbf3
...
...
@@ -25,7 +25,6 @@ class UserResource extends Resource
'registered_at'
=>
$this
->
created_at
->
toIso8601String
(),
'last_updated_at'
=>
$this
->
updated_at
->
toIso8601String
(),
];
}
}
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