Roles Update (#1474)
Adds member count to roles\index and member list to roles\edit pages. Co-authored-by: Nabeel S <nabeelio@users.noreply.github.com>
This commit is contained in:
parent
64e470abec
commit
b1ae0240be
@ -48,7 +48,7 @@ class RolesController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->rolesRepo->pushCriteria(new RequestCriteria($request));
|
$this->rolesRepo->pushCriteria(new RequestCriteria($request));
|
||||||
$roles = $this->rolesRepo->findWhere(['read_only' => false]);
|
$roles = $this->rolesRepo->withCount('users')->findWhere(['read_only' => false]);
|
||||||
|
|
||||||
return view('admin.roles.index', [
|
return view('admin.roles.index', [
|
||||||
'roles' => $roles,
|
'roles' => $roles,
|
||||||
@ -117,7 +117,7 @@ class RolesController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$role = $this->rolesRepo->findWithoutFail($id);
|
$role = $this->rolesRepo->withCount('users')->with('users')->findWithoutFail($id);
|
||||||
|
|
||||||
if (empty($role)) {
|
if (empty($role)) {
|
||||||
Flash::error('Role not found');
|
Flash::error('Role not found');
|
||||||
@ -126,6 +126,8 @@ class RolesController extends Controller
|
|||||||
|
|
||||||
return view('admin.roles.edit', [
|
return view('admin.roles.edit', [
|
||||||
'role' => $role,
|
'role' => $role,
|
||||||
|
'users' => $role->users,
|
||||||
|
'users_count' => $role->users_count,
|
||||||
'permissions' => $this->permsRepo->all(),
|
'permissions' => $this->permsRepo->all(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
<table class="table table-hover table-responsive" id="roles-table">
|
<table class="table table-hover table-responsive" id="roles-table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th></th>
|
<th class="text-center">Members</th>
|
||||||
|
<th class="text-right">Actions</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($roles as $role)
|
@foreach($roles as $role)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $role->display_name }}</td>
|
<td>{{ $role->display_name }}</td>
|
||||||
|
<td class="text-center">{{ $role->users_count }}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
{{ Form::open(['route' => ['admin.roles.destroy', $role->id], 'method' => 'delete']) }}
|
{{ Form::open(['route' => ['admin.roles.destroy', $role->id], 'method' => 'delete']) }}
|
||||||
<a href="{{ route('admin.roles.edit', [$role->id]) }}"
|
<a href="{{ route('admin.roles.edit', [$role->id]) }}"
|
||||||
|
@ -2,15 +2,20 @@
|
|||||||
<!-- Code Field -->
|
<!-- Code Field -->
|
||||||
<div class="form-group col-sm-12">
|
<div class="form-group col-sm-12">
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<h6><i class="fas fa-users"></i>
|
<h6>
|
||||||
Users
|
<i class="fas fa-users mr-2"></i>
|
||||||
|
@if($users_count > 0) {{ $users_count.' users are assigned to this role' }} @else No Users @endif
|
||||||
</h6>
|
</h6>
|
||||||
<div class="form-container-body">
|
<div class="form-container-body">
|
||||||
<div class="row">
|
@if($users_count > 0)
|
||||||
<div class="col-sm-12">
|
<div class="row">
|
||||||
TO DO
|
<div class="col-sm-12">
|
||||||
|
@foreach($users as $u)
|
||||||
|
• <a href="{{ route('admin.users.edit', [$u->id]) }}">{{ $u->ident.' '.$u->name }}</a>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user