Added the ability to manage a group of users.

This commit is contained in:
2023-07-16 19:21:09 +06:00
parent ba7e52f8ac
commit 4083e2ec5e
45 changed files with 1173 additions and 10 deletions

View File

@@ -0,0 +1,24 @@
<div class="pt-3">
<div class="h5 pb-3">{{ $title }}</div>
@error($requestName)
<span class="invalid-feedback d-block pb-3">{{ $message }}</span>
@enderror
@foreach($permissions as $mainPermission)
<div class="row ps-3">
<div class="mb-3">
<span class="h6 fw-bold">{{ $mainPermission->getTitle() }}</span>
</div>
<ul>
@foreach($mainPermission->getPermissions() as $keyPermission => $permission)
<li class="form-check">
<input class="form-check-input" type="checkbox" value="{{ $mainPermission->formatValue($keyPermission) }}" name="{{ $name }}" @checked($role->is_admin || $value->search($mainPermission->formatValue($keyPermission)) !== false) @disabled($role->is_admin) id="form-permission-{{ $requestName }}-{{ $mainPermission->name }}-{{ $keyPermission }}">
<label class="form-check-label" for="form-permission-{{ $requestName }}-{{ $mainPermission->name }}-{{ $keyPermission }}">
{{ $permission }}
</label>
</li>
@endforeach
</ul>
<hr>
</div>
@endforeach
</div>

View File

@@ -7,12 +7,28 @@
<span class="mt-1 ms-1 sidebar-text">Captcha service</span>
</a>
</li>
<li class="nav-item {{ request()->route()->named('home') ? 'active' : '' }}">
<li @class([
'nav-item',
'active' => request()->route()->named('home')
])>
<a href="{{ route('home') }}" class="nav-link">
<span class="sidebar-icon">
<svg class="icon icon-xs me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 10a8 8 0 018-8v8h8a8 8 0 11-16 0z"></path><path d="M12 2.252A8.014 8.014 0 0117.748 8H12V2.252z"></path></svg>
</span>
<span class="sidebar-text">Dashboard</span>
<span class="sidebar-text">{{ __('sections.Dashboard') }}</span>
</a>
</li>
@can('viewAny', \App\Models\Role::class)
<li @class([
'nav-item',
'active' => request()->route()->named('roles.*'),
])>
<a href="{{ route('roles.index') }}" class="nav-link">
<span class="sidebar-icon">
<svg class="icon icon-xs me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9 2a1 1 0 000 2h2a1 1 0 100-2H9z"></path><path fill-rule="evenodd" d="M4 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v11a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm3 4a1 1 0 000 2h.01a1 1 0 100-2H7zm3 0a1 1 0 000 2h3a1 1 0 100-2h-3zm-3 4a1 1 0 100 2h.01a1 1 0 100-2H7zm3 0a1 1 0 100 2h3a1 1 0 100-2h-3z" clip-rule="evenodd"></path></svg>
</span>
<span class="sidebar-text">{{ __('sections.User group') }}</span>
</a>
</li>
@endcan
</ul>

View File

@@ -0,0 +1,5 @@
@csrf
<x-private.forms.input :title="__('validation.attributes.name')" name="name" type="text" :value="$role->name" required autofocus />
<x-private.forms.permissions_for_role :title="__('validation.attributes.permissions')" name="permissions[]" :value="$role->permissions->pluck('permission')->toArray()" :role="$role" />
<x-private.forms.input :title="__('validation.attributes.code')" name="code" type="text" :value="$role->code" :disabled="!empty($role->id)" required />
<button class="btn btn-primary" type="submit">{{ __('Save') }}</button>

View File

@@ -0,0 +1,8 @@
@can('create', \App\Models\Role::class)
<div class="mb-4">
<a href="{{ route('roles.create') }}" class="btn btn-secondary d-inline-flex align-items-center me-2">
<svg class="icon icon-xs me-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path></svg>
{{ __('Create') }}
</a>
</div>
@endcan

View File

@@ -0,0 +1,16 @@
@section('meta_title', __('sections.User group'))
@section('h1', __('sections.User group'))
<x-private.layout>
@include('private.roles._top')
<div class="row">
<div class="col-12 mb-4">
<div class="card border-0 shadow components-section">
<div class="card-body">
<form method="post" action="{{ route('roles.store') }}">
@include('private.roles._from')
</form>
</div>
</div>
</div>
</div>
</x-private.layout>

View File

@@ -0,0 +1,17 @@
@section('meta_title', __('sections.User group'))
@section('h1', __('sections.User group'))
<x-private.layout>
@include('private.roles._top')
<div class="row">
<div class="col-12 mb-4">
<div class="card border-0 shadow components-section">
<div class="card-body">
<form method="post" action="{{ route('roles.update', $role) }}">
@method('PUT')
@include('private.roles._from')
</form>
</div>
</div>
</div>
</div>
</x-private.layout>

View File

@@ -0,0 +1,54 @@
@section('meta_title', __('sections.User group'))
@section('h1', __('sections.User group'))
<x-private.layout>
@include('private.roles._top')
<div class="card border-0 shadow mb-4">
<div class="card-body">
<div class="table-responsive">
<table class="table table-centered table-nowrap mb-0 rounded">
<thead class="thead-light">
<tr>
<th class="border-0">{{ __('validation.attributes.name') }}</th>
<th class="border-0">{{ __('validation.attributes.code') }}</th>
<th class="border-0 rounded-end" style="width: 150px"></th>
</tr>
</thead>
<tbody>
@foreach($roles as $role)
<tr>
<td>
<a href="{{ route('roles.edit', $role) }}" class="fw-bold">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="align-text-top" viewBox="0 0 16 16">
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
</svg>
{{ $role->name }}
</a>
</td>
<td>{{ $role->code }}</td>
<td>
@if($role->is_remove)
<form method="post" action="{{ route('roles.destroy', $role) }}">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger click-confirm">
{{ __('Delete') }}
</button>
</form>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="card-footer border-0 d-flex flex-column flex-lg-row align-items-center justify-content-between">
<nav aria-label="Пример навигации по странице">
{{ $roles->links() }}
</nav>
</div>
</div>
</div>
</div>
@push('scripts')
@include('private._scripts._click-confirm', ['alert' => __('Do you want to delete?')])
@endpush
</x-private.layout>