Added the ability to manage users.
This commit is contained in:
12
resources/views/private/components/forms/checkbox.blade.php
Normal file
12
resources/views/private/components/forms/checkbox.blade.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<div class="form-check">
|
||||
@if(!is_null($notCheckedValue))
|
||||
<input type="hidden" name="{{ $name }}" value="{{ $notCheckedValue }}">
|
||||
@endif
|
||||
<input class="form-check-input @error($requestName) is-invalid @enderror" name="{{ $name }}" type="checkbox" value="{{ $checkboxValue }}" @checked($checkboxValue === $userValue) id="form-checkbox-{{ $requestName }}">
|
||||
<label class="form-check-label" for="form-checkbox-{{ $requestName }}">
|
||||
{{ $title }}
|
||||
</label>
|
||||
@error($name)
|
||||
<span class="invalid-feedback d-block">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
@@ -0,0 +1,16 @@
|
||||
<div class="mb-4">
|
||||
<div class="h5 pb-3">{{ $title }}</div>
|
||||
@error($requestName)
|
||||
<span class="invalid-feedback d-block pb-3">{{ $message }}</span>
|
||||
@enderror
|
||||
<div class="row">
|
||||
@foreach($list as $elementValue => $elementTitle)
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="{{ $name }}" value="{{ $elementValue }}" @checked(array_search($elementValue, $value) !== false) id="form-checkbox-{{ $requestName }}-{{ $loop->index }}">
|
||||
<label class="form-check-label" for="form-checkbox-{{ $requestName }}-{{ $loop->index }}">
|
||||
{{ $elementTitle }}
|
||||
</label>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
@@ -18,6 +18,21 @@
|
||||
<span class="sidebar-text">{{ __('sections.Dashboard') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@can('viewAny', \App\Models\User::class)
|
||||
<li @class([
|
||||
'nav-item',
|
||||
'active' => request()->route()->named('users.*'),
|
||||
])>
|
||||
<a href="{{ route('users.index') }}" class="nav-link">
|
||||
<span class="sidebar-icon">
|
||||
<svg class="icon icon-xs me-2" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1h8Zm-7.978-1A.261.261 0 0 1 7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002a.274.274 0 0 1-.014.002H7.022ZM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM6.936 9.28a5.88 5.88 0 0 0-1.23-.247A7.35 7.35 0 0 0 5 9c-4 0-5 3-5 4 0 .667.333 1 1 1h4.216A2.238 2.238 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816ZM4.92 10A5.493 5.493 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275ZM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0Zm3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4Z"/></svg>
|
||||
</span>
|
||||
<span class="sidebar-text">{{ __('sections.Users') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('viewAny', \App\Models\Role::class)
|
||||
<li @class([
|
||||
'nav-item',
|
||||
|
@@ -55,7 +55,7 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="content min-vh-100 position-relative">
|
||||
<main class="content min-vh-100 position-relative pb-7 pb-lg-5">
|
||||
|
||||
<nav class="navbar navbar-top navbar-expand navbar-dashboard navbar-dark ps-0 pe-2 pb-2 pb-lg-3">
|
||||
<div class="container-fluid px-0">
|
||||
|
13
resources/views/private/users/_from.blade.php
Normal file
13
resources/views/private/users/_from.blade.php
Normal file
@@ -0,0 +1,13 @@
|
||||
@csrf
|
||||
<x-private.forms.checkbox :title="__('validation.attributes.is_active')" name="is_active" checkboxValue="1" notCheckedValue="0" :userValue="(string) $user->is_active" />
|
||||
<x-private.forms.input :title="__('validation.attributes.name')" name="name" type="text" :value="$user->name" required autofocus />
|
||||
<x-private.forms.input :title="__('validation.attributes.email')" name="email" type="email" :value="$user->email" required />
|
||||
@if (empty($user->id))
|
||||
<x-private.forms.input :title="__('validation.attributes.password')" name="password" type="password" value="" required autocomplete="off" />
|
||||
@endif
|
||||
<hr>
|
||||
<x-private.forms.multi_checkbox :title="__('validation.attributes.roles')" name="roles[]" :list="$roles" :value="$userRoles" />
|
||||
<hr>
|
||||
@canany(['create', 'update'], $user)
|
||||
<button class="btn btn-primary" type="submit">{{ __('Save') }}</button>
|
||||
@endcanany
|
8
resources/views/private/users/_top.blade.php
Normal file
8
resources/views/private/users/_top.blade.php
Normal file
@@ -0,0 +1,8 @@
|
||||
@can('create', \App\Models\User::class)
|
||||
<div class="mb-4">
|
||||
<a href="{{ route('users.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
|
16
resources/views/private/users/create.blade.php
Normal file
16
resources/views/private/users/create.blade.php
Normal file
@@ -0,0 +1,16 @@
|
||||
@section('meta_title', __('sections.Users'))
|
||||
@section('h1', __('sections.Users'))
|
||||
<x-private.layout>
|
||||
@include('private.users._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('users.store') }}">
|
||||
@include('private.users._from')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-private.layout>
|
34
resources/views/private/users/edit.blade.php
Normal file
34
resources/views/private/users/edit.blade.php
Normal file
@@ -0,0 +1,34 @@
|
||||
@section('meta_title', __('sections.Users'))
|
||||
@section('h1', __('sections.Users'))
|
||||
<x-private.layout>
|
||||
@include('private.users._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('users.update', $user) }}">
|
||||
@method('PUT')
|
||||
@include('private.users._from')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@can('update', $user)
|
||||
<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('users.update-password', $user) }}">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
<x-private.forms.input :title="__('validation.attributes.password')" name="password" type="password" value="" required autocomplete="off" />
|
||||
<button class="btn btn-primary" type="submit">{{ __('Save') }}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
</x-private.layout>
|
60
resources/views/private/users/index.blade.php
Normal file
60
resources/views/private/users/index.blade.php
Normal file
@@ -0,0 +1,60 @@
|
||||
@section('meta_title', __('sections.Users'))
|
||||
@section('h1', __('sections.Users'))
|
||||
<x-private.layout>
|
||||
@include('private.users._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.email') }}</th>
|
||||
<th class="border-0">{{ __('validation.attributes.is_active') }}</th>
|
||||
<th class="border-0 rounded-end" style="width: 150px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($users as $user)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('users.edit', $user) }}" 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>
|
||||
{{ $user->name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ $user->email }}</td>
|
||||
<td>
|
||||
@if($user->is_active)
|
||||
{{ __('yes') }}
|
||||
@else
|
||||
{{ __('no') }}
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@can('delete', $user)
|
||||
<form method="post" action="{{ route('users.destroy', $user) }}">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger click-confirm">
|
||||
{{ __('Delete') }}
|
||||
</button>
|
||||
</form>
|
||||
@endcan
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card-footer border-0">
|
||||
{{ $users->links() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@push('scripts')
|
||||
@include('private._scripts._click-confirm', ['alert' => __('Do you want to delete?')])
|
||||
@endpush
|
||||
</x-private.layout>
|
Reference in New Issue
Block a user