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
d24e4825
Commit
d24e4825
authored
May 16, 2018
by
Vipul Basapati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Role Module Response Interface integration complete
parent
c7c71028
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
217 additions
and
50 deletions
+217
-50
RoleController.php
app/Http/Controllers/Backend/Access/Role/RoleController.php
+32
-33
UserController.php
app/Http/Controllers/Backend/Access/User/UserController.php
+14
-14
UserTableController.php
...p/Controllers/Backend/Access/User/UserTableController.php
+3
-3
CreateResponse.php
app/Http/Responses/Backend/Access/Role/CreateResponse.php
+42
-0
EditResponse.php
app/Http/Responses/Backend/Access/Role/EditResponse.php
+42
-0
ShowResponse.php
app/Http/Responses/Backend/Access/Role/ShowResponse.php
+33
-0
EditResponse.php
app/Http/Responses/Backend/Access/User/EditResponse.php
+6
-0
ViewResponse.php
app/Http/Responses/ViewResponse.php
+45
-0
No files found.
app/Http/Controllers/Backend/Access/Role/RoleController.php
View file @
d24e4825
...
@@ -2,16 +2,20 @@
...
@@ -2,16 +2,20 @@
namespace
App\Http\Controllers\Backend\Access\Role
;
namespace
App\Http\Controllers\Backend\Access\Role
;
use
App\Models\Access\Role\Role
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
App\Http\Responses\ViewResponse
;
use
App\Http\Responses\RedirectResponse
;
use
App\Http\Responses\Backend\Access\Role\EditResponse
;
use
App\Repositories\Backend\Access\Role\RoleRepository
;
use
App\Http\Requests\Backend\Access\Role\EditRoleRequest
;
use
App\Http\Responses\Backend\Access\Role\CreateResponse
;
use
App\Http\Requests\Backend\Access\Role\StoreRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\CreateRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\CreateRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\DeleteRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\DeleteRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\EditRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\ManageRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\ManageRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\StoreRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\UpdateRoleRequest
;
use
App\Http\Requests\Backend\Access\Role\UpdateRoleRequest
;
use
App\Models\Access\Role\Role
;
use
App\Repositories\Backend\Access\Permission\PermissionRepository
;
use
App\Repositories\Backend\Access\Permission\PermissionRepository
;
use
App\Repositories\Backend\Access\Role\RoleRepository
;
/**
/**
* Class RoleController.
* Class RoleController.
...
@@ -19,18 +23,18 @@ use App\Repositories\Backend\Access\Role\RoleRepository;
...
@@ -19,18 +23,18 @@ use App\Repositories\Backend\Access\Role\RoleRepository;
class
RoleController
extends
Controller
class
RoleController
extends
Controller
{
{
/**
/**
* @var RoleRepository
* @var
\App\Repositories\Backend\Access\Role\
RoleRepository
*/
*/
protected
$roles
;
protected
$roles
;
/**
/**
* @var PermissionRepository
* @var
\App\Repositories\Backend\Access\Permission\
PermissionRepository
*/
*/
protected
$permissions
;
protected
$permissions
;
/**
/**
* @param
RoleRepository
$roles
* @param
\App\Repositories\Backend\Access\Role\RoleRepository
$roles
* @param
PermissionRepository
$permissions
* @param
\App\Repositories\Backend\Access\Permission\PermissionRepository
$permissions
*/
*/
public
function
__construct
(
RoleRepository
$roles
,
PermissionRepository
$permissions
)
public
function
__construct
(
RoleRepository
$roles
,
PermissionRepository
$permissions
)
{
{
...
@@ -39,76 +43,71 @@ class RoleController extends Controller
...
@@ -39,76 +43,71 @@ class RoleController extends Controller
}
}
/**
/**
* @param ManageRoleRequest $request
* @param
\App\Http\Requests\Backend\Access\Role\
ManageRoleRequest $request
*
*
* @return mixed
* @return mixed
*/
*/
public
function
index
(
ManageRoleRequest
$request
)
public
function
index
(
ManageRoleRequest
$request
)
{
{
return
view
(
'backend.access.roles.index'
);
return
new
ViewResponse
(
'backend.access.roles.index'
);
}
}
/**
/**
* @param CreateRoleRequest $request
* @param
\App\Http\Requests\Backend\Access\Role\
CreateRoleRequest $request
*
*
* @return
mixed
* @return
\App\Http\Responses\Backend\Access\Role\CreateResponse
*/
*/
public
function
create
(
CreateRoleRequest
$request
)
public
function
create
(
CreateRoleRequest
$request
)
{
{
return
view
(
'backend.access.roles.create'
)
return
new
CreateResponse
(
$this
->
permissions
,
$this
->
roles
);
->
withPermissions
(
$this
->
permissions
->
getAll
())
->
withRoleCount
(
$this
->
roles
->
getCount
());
}
}
/**
/**
* @param StoreRoleRequest $request
* @param
\App\Http\Requests\Backend\Access\Role\
StoreRoleRequest $request
*
*
* @return
mixed
* @return
\App\Http\Responses\RedirectResponse
*/
*/
public
function
store
(
StoreRoleRequest
$request
)
public
function
store
(
StoreRoleRequest
$request
)
{
{
$this
->
roles
->
create
(
$request
->
all
());
$this
->
roles
->
create
(
$request
->
all
());
return
redirect
()
->
route
(
'admin.access.role.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.roles.created'
)
);
return
new
RedirectResponse
(
'admin.access.role.index'
,
[
'flash_success'
=>
trans
(
'alerts.backend.roles.created'
)]
);
}
}
/**
/**
* @param
Role
$role
* @param
\App\Models\Access\Role\Role
$role
* @param
EditRoleRequest
$request
* @param
\App\Http\Requests\Backend\Access\Role\EditRoleRequest
$request
*
*
* @return
mixed
* @return
\App\Http\Responses\Backend\Access\Role\EditResponse
*/
*/
public
function
edit
(
Role
$role
,
EditRoleRequest
$request
)
public
function
edit
(
Role
$role
,
EditRoleRequest
$request
)
{
{
return
view
(
'backend.access.roles.edit'
)
return
new
EditResponse
(
$role
,
$this
->
permissions
);
->
withRole
(
$role
)
->
withRolePermissions
(
$role
->
permissions
->
pluck
(
'id'
)
->
all
())
->
withPermissions
(
$this
->
permissions
->
getAll
());
}
}
/**
/**
* @param
Role
$role
* @param
\App\Models\Access\Role\Role
$role
* @param
UpdateRoleRequest
$request
* @param
\App\Http\Requests\Backend\Access\Role\UpdateRoleRequest
$request
*
*
* @return
mixed
* @return
\App\Http\Responses\RedirectResponse
*/
*/
public
function
update
(
Role
$role
,
UpdateRoleRequest
$request
)
public
function
update
(
Role
$role
,
UpdateRoleRequest
$request
)
{
{
$this
->
roles
->
update
(
$role
,
$request
->
all
());
$this
->
roles
->
update
(
$role
,
$request
->
all
());
return
redirect
()
->
route
(
'admin.access.role.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.roles.updated'
)
);
return
new
RedirectResponse
(
'admin.access.role.index'
,
[
'flash_success'
=>
trans
(
'alerts.backend.roles.updated'
)]
);
}
}
/**
/**
* @param
Role
$role
* @param
\App\Models\Access\Role\Role
$role
* @param
DeleteRoleRequest
$request
* @param
\App\Http\Requests\Backend\Access\Role\DeleteRoleRequest
$request
*
*
* @return
mixed
* @return
\App\Http\Responses\RedirectResponse
*/
*/
public
function
destroy
(
Role
$role
,
DeleteRoleRequest
$request
)
public
function
destroy
(
Role
$role
,
DeleteRoleRequest
$request
)
{
{
$this
->
roles
->
delete
(
$role
);
$this
->
roles
->
delete
(
$role
);
return
redirect
()
->
route
(
'admin.access.role.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.roles.deleted'
));
return
new
RedirectResponse
(
'admin.access.role.index'
,
[
'flash_success'
=>
trans
(
'alerts.backend.roles.deleted'
)]);
}
}
}
}
app/Http/Controllers/Backend/Access/User/UserController.php
View file @
d24e4825
...
@@ -2,23 +2,23 @@
...
@@ -2,23 +2,23 @@
namespace
App\Http\Controllers\Backend\Access\User
;
namespace
App\Http\Controllers\Backend\Access\User
;
use
App\Models\Access\User\User
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
App\Http\Requests\Backend\Access\User\CreateUserRequest
;
use
App\Http\Responses\ViewResponse
;
use
App\Http\Requests\Backend\Access\User\DeleteUserRequest
;
use
App\Http\Requests\Backend\Access\User\EditUserRequest
;
use
App\Http\Requests\Backend\Access\User\ManageUserRequest
;
use
App\Http\Requests\Backend\Access\User\ShowUserRequest
;
use
App\Http\Requests\Backend\Access\User\StoreUserRequest
;
use
App\Http\Requests\Backend\Access\User\UpdateUserRequest
;
use
App\Http\Responses\Backend\Access\User\CreateResponse
;
use
App\Http\Responses\Backend\Access\User\EditResponse
;
use
App\Http\Responses\Backend\Access\User\IndexResponse
;
use
App\Http\Responses\Backend\Access\User\ShowResponse
;
use
App\Http\Responses\RedirectResponse
;
use
App\Http\Responses\RedirectResponse
;
use
App\Models\Access\Permission\Permission
;
use
App\Models\Access\Permission\Permission
;
use
App\Models\Access\User\User
;
use
App\Http\Responses\Backend\Access\User\EditResponse
;
use
App\Http\Responses\Backend\Access\User\ShowResponse
;
use
App\Repositories\Backend\Access\Role\RoleRepository
;
use
App\Repositories\Backend\Access\Role\RoleRepository
;
use
App\Repositories\Backend\Access\User\UserRepository
;
use
App\Repositories\Backend\Access\User\UserRepository
;
use
App\Http\Requests\Backend\Access\User\EditUserRequest
;
use
App\Http\Requests\Backend\Access\User\ShowUserRequest
;
use
App\Http\Responses\Backend\Access\User\CreateResponse
;
use
App\Http\Requests\Backend\Access\User\StoreUserRequest
;
use
App\Http\Requests\Backend\Access\User\CreateUserRequest
;
use
App\Http\Requests\Backend\Access\User\DeleteUserRequest
;
use
App\Http\Requests\Backend\Access\User\ManageUserRequest
;
use
App\Http\Requests\Backend\Access\User\UpdateUserRequest
;
/**
/**
* Class UserController.
* Class UserController.
...
@@ -48,11 +48,11 @@ class UserController extends Controller
...
@@ -48,11 +48,11 @@ class UserController extends Controller
/**
/**
* @param \App\Http\Requests\Backend\Access\User\ManageUserRequest $request
* @param \App\Http\Requests\Backend\Access\User\ManageUserRequest $request
*
*
* @return \App\Http\Responses\
Backend\Access\User\Index
Response
* @return \App\Http\Responses\
View
Response
*/
*/
public
function
index
(
ManageUserRequest
$request
)
public
function
index
(
ManageUserRequest
$request
)
{
{
return
new
IndexResponse
(
);
return
new
ViewResponse
(
'backend.access.users.index'
);
}
}
/**
/**
...
...
app/Http/Controllers/Backend/Access/User/UserTableController.php
View file @
d24e4825
...
@@ -14,12 +14,12 @@ use Yajra\DataTables\Facades\DataTables;
...
@@ -14,12 +14,12 @@ use Yajra\DataTables\Facades\DataTables;
class
UserTableController
extends
Controller
class
UserTableController
extends
Controller
{
{
/**
/**
* @var UserRepository
* @var
\App\Repositories\Backend\Access\User\
UserRepository
*/
*/
protected
$users
;
protected
$users
;
/**
/**
* @param UserRepository $users
* @param
\App\Repositories\Backend\Access\User\
UserRepository $users
*/
*/
public
function
__construct
(
UserRepository
$users
)
public
function
__construct
(
UserRepository
$users
)
{
{
...
@@ -27,7 +27,7 @@ class UserTableController extends Controller
...
@@ -27,7 +27,7 @@ class UserTableController extends Controller
}
}
/**
/**
* @param ManageUserRequest $request
* @param
\App\Http\Requests\Backend\Access\User\
ManageUserRequest $request
*
*
* @return mixed
* @return mixed
*/
*/
...
...
app/Http/Responses/Backend/Access/Role/CreateResponse.php
0 → 100644
View file @
d24e4825
<?php
namespace
App\Http\Responses\Backend\Access\Role
;
use
Illuminate\Contracts\Support\Responsable
;
class
CreateResponse
implements
Responsable
{
/**
* @var \App\Repositories\Backend\Access\Role\RoleRepository
*/
protected
$roles
;
/**
* @var \App\Repositories\Backend\Access\Permission\PermissionRepository
*/
protected
$permissions
;
/**
* @param \App\Repositories\Backend\Access\Permission\PermissionRepository $permissions
* @param \App\Repositories\Backend\Access\Role\RoleRepository $roles
*/
public
function
__construct
(
$permissions
,
$roles
)
{
$this
->
permissions
=
$permissions
;
$this
->
roles
=
$roles
;
}
/**
* In Response.
*
* @param \App\Http\Requests\Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public
function
toResponse
(
$request
)
{
return
view
(
'backend.access.roles.create'
)
->
withPermissions
(
$this
->
permissions
->
getAll
())
->
withRoleCount
(
$this
->
roles
->
getCount
());
}
}
app/Http/Responses/Backend/Access/Role/EditResponse.php
0 → 100644
View file @
d24e4825
<?php
namespace
App\Http\Responses\Backend\Access\Role
;
use
Illuminate\Contracts\Support\Responsable
;
class
EditResponse
implements
Responsable
{
/**
* @var \App\Models\Access\Role\Role
*/
protected
$role
;
/**
* @var \App\Repositories\Backend\Access\Permission\PermissionRepository
*/
protected
$permissions
;
/**
* @param \App\Models\Access\Role\Role $role
* @param \App\Repositories\Backend\Access\Permission\PermissionRepository $permissions
*/
public
function
__construct
(
$role
,
$permissions
)
{
$this
->
role
=
$role
;
$this
->
permissions
=
$permissions
;
}
/**
* toReponse
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public
function
toResponse
(
$request
)
{
return
view
(
'backend.access.roles.edit'
)
->
withRole
(
$this
->
role
)
->
withRolePermissions
(
$this
->
role
->
permissions
->
pluck
(
'id'
)
->
all
())
->
withPermissions
(
$this
->
permissions
->
getAll
());
}
}
app/Http/Responses/Backend/Access/
User/Index
Response.php
→
app/Http/Responses/Backend/Access/
Role/Show
Response.php
View file @
d24e4825
...
@@ -4,8 +4,21 @@ namespace App\Http\Responses\Backend\Access\User;
...
@@ -4,8 +4,21 @@ namespace App\Http\Responses\Backend\Access\User;
use
Illuminate\Contracts\Support\Responsable
;
use
Illuminate\Contracts\Support\Responsable
;
class
Index
Response
implements
Responsable
class
Show
Response
implements
Responsable
{
{
/**
* @var \App\Models\Access\User\User
*/
protected
$user
;
/**
* @param \App\Models\Access\User\User $user
*/
public
function
__construct
(
$user
)
{
$this
->
user
=
$user
;
}
/**
/**
* In Response.
* In Response.
*
*
...
@@ -15,6 +28,6 @@ class IndexResponse implements Responsable
...
@@ -15,6 +28,6 @@ class IndexResponse implements Responsable
*/
*/
public
function
toResponse
(
$request
)
public
function
toResponse
(
$request
)
{
{
return
view
(
'backend.access.users.
index'
);
return
view
(
'backend.access.users.
show'
)
->
withUser
(
$this
->
user
);
}
}
}
}
app/Http/Responses/Backend/Access/User/EditResponse.php
View file @
d24e4825
...
@@ -31,6 +31,12 @@ class EditResponse implements Responsable
...
@@ -31,6 +31,12 @@ class EditResponse implements Responsable
$this
->
permissions
=
$permissions
;
$this
->
permissions
=
$permissions
;
}
}
/**
* toReponse
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public
function
toResponse
(
$request
)
public
function
toResponse
(
$request
)
{
{
$permissions
=
$this
->
permissions
;
$permissions
=
$this
->
permissions
;
...
...
app/Http/Responses/ViewResponse.php
0 → 100644
View file @
d24e4825
<?php
namespace
App\Http\Responses
;
use
Illuminate\Contracts\Support\Responsable
;
class
ViewResponse
implements
Responsable
{
/**
* @var String
*/
protected
$view
;
/**
* @var Array
*/
protected
$with
;
/**
* @param String $view
* @param Array $with
*/
public
function
__construct
(
$view
,
$with
=
[])
{
$this
->
view
=
$view
;
$this
->
with
=
$with
;
}
/**
* In Response.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public
function
toResponse
(
$request
)
{
if
(
!
empty
(
$this
->
with
))
{
return
view
(
$this
->
view
)
->
with
(
$this
->
with
);
}
return
view
(
$this
->
view
);
}
}
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