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
7572012a
Unverified
Commit
7572012a
authored
May 07, 2018
by
Viral Solani
Committed by
GitHub
May 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #218 from bvipul/develop
Added Responses to User Module
parents
71ff81f3
f223677d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
181 additions
and
48 deletions
+181
-48
UserController.php
app/Http/Controllers/Backend/Access/User/UserController.php
+46
-48
CreateResponse.php
app/Http/Responses/Backend/Access/User/CreateResponse.php
+35
-0
EditResponse.php
app/Http/Responses/Backend/Access/User/EditResponse.php
+47
-0
IndexResponse.php
app/Http/Responses/Backend/Access/User/IndexResponse.php
+20
-0
ShowResponse.php
app/Http/Responses/Backend/Access/User/ShowResponse.php
+33
-0
No files found.
app/Http/Controllers/Backend/Access/User/UserController.php
View file @
7572012a
...
@@ -2,18 +2,23 @@
...
@@ -2,18 +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\RedirectResponse
;
use
App\Http\Requests\Backend\Access\User\DeleteUserRequest
;
use
App\Models\Access\Permission\Permission
;
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\User\UserRepository
;
use
App\Http\Responses\Backend\Access\User\IndexResponse
;
use
App\Http\Requests\Backend\Access\User\EditUserRequest
;
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\ShowUserRequest
;
use
App\Http\Responses\Backend\Access\User\CreateResponse
;
use
App\Http\Requests\Backend\Access\User\StoreUserRequest
;
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
;
use
App\Http\Requests\Backend\Access\User\UpdateUserRequest
;
use
App\Models\Access\Permission\Permission
;
use
App\Models\Access\User\User
;
use
App\Repositories\Backend\Access\Role\RoleRepository
;
use
App\Repositories\Backend\Access\User\UserRepository
;
/**
/**
* Class UserController.
* Class UserController.
...
@@ -21,18 +26,18 @@ use App\Repositories\Backend\Access\User\UserRepository;
...
@@ -21,18 +26,18 @@ use App\Repositories\Backend\Access\User\UserRepository;
class
UserController
extends
Controller
class
UserController
extends
Controller
{
{
/**
/**
* @var UserRepository
* @var
\App\Repositories\Backend\Access\User\
UserRepository
*/
*/
protected
$users
;
protected
$users
;
/**
/**
* @var RoleRepository
* @var
\App\Repositories\Backend\Access\Role\
RoleRepository
*/
*/
protected
$roles
;
protected
$roles
;
/**
/**
* @param UserRepository $users
* @param
\App\Repositories\Backend\Access\User\
UserRepository $users
* @param RoleRepository $roles
* @param
\App\Repositories\Backend\Access\Role\
RoleRepository $roles
*/
*/
public
function
__construct
(
UserRepository
$users
,
RoleRepository
$roles
)
public
function
__construct
(
UserRepository
$users
,
RoleRepository
$roles
)
{
{
...
@@ -41,94 +46,87 @@ class UserController extends Controller
...
@@ -41,94 +46,87 @@ class UserController extends Controller
}
}
/**
/**
* @param ManageUserRequest $request
* @param
\App\Http\Requests\Backend\Access\User\
ManageUserRequest $request
*
*
* @return \
Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @return \
App\Http\Responses\Backend\Access\User\IndexResponse
*/
*/
public
function
index
(
ManageUserRequest
$request
)
public
function
index
(
ManageUserRequest
$request
)
{
{
return
view
(
'backend.access.users.index'
);
return
new
IndexResponse
(
);
}
}
/**
/**
* @param CreateUserRequest $request
* @param
\App\Http\Requests\Backend\Access\User\
CreateUserRequest $request
*
*
* @return
mixed
* @return
\App\Http\Responses\Backend\Access\User\CreateResponse
*/
*/
public
function
create
(
CreateUserRequest
$request
)
public
function
create
(
CreateUserRequest
$request
)
{
{
return
view
(
'backend.access.users.create'
)
->
with
([
$roles
=
$this
->
roles
->
getAll
();
'roles'
=>
$this
->
roles
->
getAll
(),
]
);
return
new
CreateResponse
(
$roles
);
}
}
/**
/**
* @param StoreUserRequest $request
* @param
\App\Http\Requests\Backend\Access\User\
StoreUserRequest $request
*
*
* @return
mixed
* @return
\App\Http\Responses\RedirectResponse
*/
*/
public
function
store
(
StoreUserRequest
$request
)
public
function
store
(
StoreUserRequest
$request
)
{
{
$this
->
users
->
create
(
$request
);
$this
->
users
->
create
(
$request
);
return
redirect
()
->
route
(
'admin.access.user.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.users.created'
)
);
return
new
RedirectResponse
(
'admin.access.user.index'
,
[
'flash_success'
=>
trans
(
'alerts.backend.users.created'
)]
);
}
}
/**
/**
* @param
User
$user
* @param
\App\Models\Access\User\User
$user
* @param
ShowUserRequest
$request
* @param
\App\Http\Requests\Backend\Access\User\ShowUserRequest
$request
*
*
* @return
mixed
* @return
\App\Http\Responses\Backend\Access\User\ShowResponse
*/
*/
public
function
show
(
User
$user
,
ShowUserRequest
$request
)
public
function
show
(
User
$user
,
ShowUserRequest
$request
)
{
{
return
view
(
'backend.access.users.show'
)
return
new
ShowResponse
(
$user
);
->
withUser
(
$user
);
}
}
/**
/**
* @param
User
$user
* @param
\App\Models\Access\User\User
$user
* @param
EditUserRequest
$request
* @param
\App\Http\Requests\Backend\Access\User\EditUserRequest
$request
*
*
* @return
mixed
* @return
\App\Http\Responses\Backend\Access\User\EditResponse
*/
*/
public
function
edit
(
User
$user
,
EditUserRequest
$request
)
public
function
edit
(
User
$user
,
EditUserRequest
$request
)
{
{
$roles
=
$this
->
roles
->
getAll
();
$permissions
=
Permission
::
getSelectData
(
'display_name'
);
$permissions
=
Permission
::
getSelectData
(
'display_name'
);
$userPermissions
=
$user
->
permissions
()
->
get
()
->
pluck
(
'id'
)
->
toArray
();
return
new
EditResponse
(
$user
,
$roles
,
$permissions
);
return
view
(
'backend.access.users.edit'
)
->
with
([
'user'
=>
$user
,
'userRoles'
=>
$user
->
roles
->
pluck
(
'id'
)
->
all
(),
'roles'
=>
$this
->
roles
->
getAll
(),
'userPermissions'
=>
$userPermissions
,
'permissions'
=>
$permissions
,
]);
}
}
/**
/**
* @param
User
$user
* @param
\App\Models\Access\User\User
$user
* @param
UpdateUserRequest
$request
* @param
\App\Http\Requests\Backend\Access\User\UpdateUserRequest
$request
*
*
* @return
mixed
* @return
\App\Http\Responses\RedirectResponse
*/
*/
public
function
update
(
User
$user
,
UpdateUserRequest
$request
)
public
function
update
(
User
$user
,
UpdateUserRequest
$request
)
{
{
$this
->
users
->
update
(
$user
,
$request
);
$this
->
users
->
update
(
$user
,
$request
);
return
redirect
()
->
route
(
'admin.access.user.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.users.updated'
)
);
return
new
RedirectResponse
(
'admin.access.user.index'
,
[
'flash_success'
=>
trans
(
'alerts.backend.users.updated'
)]
);
}
}
/**
/**
* @param
User
$user
* @param
\App\Models\Access\User\User
$user
* @param
DeleteUserRequest
$request
* @param
\App\Http\Requests\Backend\Access\User\DeleteUserRequest
$request
*
*
* @return
mixed
* @return
\App\Http\Responses\RedirectResponse
*/
*/
public
function
destroy
(
User
$user
,
DeleteUserRequest
$request
)
public
function
destroy
(
User
$user
,
DeleteUserRequest
$request
)
{
{
$this
->
users
->
delete
(
$user
);
$this
->
users
->
delete
(
$user
);
return
redirect
()
->
route
(
'admin.access.user.deleted'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.users.deleted'
)
);
return
new
RedirectResponse
(
'admin.access.user.index'
,
[
'flash_success'
=>
trans
(
'alerts.backend.users.deleted'
)]
);
}
}
}
}
app/Http/Responses/Backend/Access/User/CreateResponse.php
0 → 100644
View file @
7572012a
<?php
namespace
App\Http\Responses\Backend\Access\User
;
use
Illuminate\Contracts\Support\Responsable
;
class
CreateResponse
implements
Responsable
{
/**
* @var \App\Models\Access\Role\Role
*/
protected
$roles
;
/**
* @param \Illuminate\Database\Eloquent\Collection $roles
*/
public
function
__construct
(
$roles
)
{
$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.users.create'
)
->
with
([
'roles'
=>
$this
->
roles
,
]);
}
}
app/Http/Responses/Backend/Access/User/EditResponse.php
0 → 100644
View file @
7572012a
<?php
namespace
App\Http\Responses\Backend\Access\User
;
use
Illuminate\Contracts\Support\Responsable
;
class
EditResponse
implements
Responsable
{
/**
* @var \App\Models\Access\User\User
*/
protected
$user
;
/**
* @var \App\Models\Access\Permission\Permission
*/
protected
$permissions
;
/**
* @var \App\Models\Access\Role\Role
*/
protected
$roles
;
/**
* @param \App\Models\Access\User\User $user
*/
public
function
__construct
(
$user
,
$roles
,
$permissions
)
{
$this
->
user
=
$user
;
$this
->
roles
=
$roles
;
$this
->
permissions
=
$permissions
;
}
public
function
toResponse
(
$request
)
{
$permissions
=
$this
->
permissions
;
$userPermissions
=
$this
->
user
->
permissions
()
->
get
()
->
pluck
(
'id'
)
->
toArray
();
return
view
(
'backend.access.users.edit'
)
->
with
([
'user'
=>
$this
->
user
,
'userRoles'
=>
$this
->
user
->
roles
->
pluck
(
'id'
)
->
all
(),
'roles'
=>
$this
->
roles
,
'userPermissions'
=>
$userPermissions
,
'permissions'
=>
$permissions
,
]);
}
}
app/Http/Responses/Backend/Access/User/IndexResponse.php
0 → 100644
View file @
7572012a
<?php
namespace
App\Http\Responses\Backend\Access\User
;
use
Illuminate\Contracts\Support\Responsable
;
class
IndexResponse
implements
Responsable
{
/**
* In Response
*
* @param \App\Http\Requests\Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public
function
toResponse
(
$request
)
{
return
view
(
'backend.access.users.index'
);
}
}
app/Http/Responses/Backend/Access/User/ShowResponse.php
0 → 100644
View file @
7572012a
<?php
namespace
App\Http\Responses\Backend\Access\User
;
use
Illuminate\Contracts\Support\Responsable
;
class
ShowResponse
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
*
* @param \App\Http\Requests\Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public
function
toResponse
(
$request
)
{
return
view
(
'backend.access.users.show'
)
->
withUser
(
$this
->
user
);
}
}
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