feat: implement admin management
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="col-xl-12">
|
||||
|
||||
<form
|
||||
@@ -52,9 +52,7 @@
|
||||
method="POST"
|
||||
enctype="multipart/form-data"
|
||||
>
|
||||
|
||||
<?php echo csrf_field(); ?>
|
||||
|
||||
<div class="card custom-card">
|
||||
|
||||
|
||||
@@ -63,8 +61,6 @@
|
||||
ایجاد مدیر
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
@@ -258,22 +254,17 @@ unset($__errorArgs, $__bag); ?>
|
||||
<select
|
||||
class="form-control"
|
||||
name="role"
|
||||
id="adminRole"
|
||||
>
|
||||
|
||||
<?php $__currentLoopData = \App\Enums\Admin\AdminRole::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
<option
|
||||
value="<?php echo e($role->value); ?>"
|
||||
<?php if(
|
||||
old('role') == $role->value
|
||||
): echo 'selected'; endif; ?>
|
||||
<?php if(old('role') == $role->value): echo 'selected'; endif; ?>
|
||||
>
|
||||
<?php echo e($role->label()); ?>
|
||||
|
||||
</option>
|
||||
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
</select>
|
||||
|
||||
<?php $__errorArgs = ['role'];
|
||||
@@ -282,9 +273,9 @@ if ($__bag->has($__errorArgs[0])) :
|
||||
if (isset($message)) { $__messageOriginal = $message; }
|
||||
$message = $__bag->first($__errorArgs[0]); ?>
|
||||
<span class="text-danger">
|
||||
<?php echo e($message); ?>
|
||||
<?php echo e($message); ?>
|
||||
|
||||
</span>
|
||||
</span>
|
||||
<?php unset($message);
|
||||
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
|
||||
endif;
|
||||
@@ -341,7 +332,7 @@ unset($__errorArgs, $__bag); ?>
|
||||
|
||||
|
||||
|
||||
<div class="mt-4">
|
||||
<div class="col-xl-12 mt-4">
|
||||
|
||||
<div class="card custom-card">
|
||||
|
||||
@@ -356,14 +347,18 @@ unset($__errorArgs, $__bag); ?>
|
||||
<div class="row gy-3">
|
||||
|
||||
<?php $__currentLoopData = \App\Enums\Admin\AdminPermission::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $permission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
<div class="col-xl-3 col-lg-4 col-md-6">
|
||||
|
||||
<div class="form-check">
|
||||
|
||||
<input
|
||||
class="form-check-input"
|
||||
class="form-check-input permission-checkbox"
|
||||
type="checkbox"
|
||||
name="permissions[]"
|
||||
value="<?php echo e($permission->value); ?>"
|
||||
id="permission_<?php echo e($permission->value); ?>"
|
||||
data-permission="<?php echo e($permission->value); ?>"
|
||||
|
||||
<?php if(
|
||||
in_array(
|
||||
@@ -389,18 +384,15 @@ unset($__errorArgs, $__bag); ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php $__errorArgs = ['permissions'];
|
||||
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
|
||||
if ($__bag->has($__errorArgs[0])) :
|
||||
if (isset($message)) { $__messageOriginal = $message; }
|
||||
$message = $__bag->first($__errorArgs[0]); ?>
|
||||
<div class="mt-2">
|
||||
<span class="text-danger">
|
||||
<?php echo e($message); ?>
|
||||
<span class="text-danger">
|
||||
<?php echo e($message); ?>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
<?php unset($message);
|
||||
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
|
||||
endif;
|
||||
@@ -411,12 +403,10 @@ $__bag = $errors->getBag($__errorArgs[1] ?? 'default');
|
||||
if ($__bag->has($__errorArgs[0])) :
|
||||
if (isset($message)) { $__messageOriginal = $message; }
|
||||
$message = $__bag->first($__errorArgs[0]); ?>
|
||||
<div class="mt-2">
|
||||
<span class="text-danger">
|
||||
<?php echo e($message); ?>
|
||||
<span class="text-danger">
|
||||
<?php echo e($message); ?>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
<?php unset($message);
|
||||
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
|
||||
endif;
|
||||
@@ -454,6 +444,7 @@ unset($__errorArgs, $__bag); ?>
|
||||
onchange="previewAvatar(this)"
|
||||
>
|
||||
|
||||
|
||||
</label>
|
||||
|
||||
</div>
|
||||
@@ -509,29 +500,63 @@ unset($__errorArgs, $__bag); ?>
|
||||
|
||||
</div>
|
||||
<?php $__env->stopSection(); ?>
|
||||
|
||||
|
||||
<?php $__env->startPush('scripts'); ?>
|
||||
|
||||
<script>
|
||||
function previewAvatar(input) {
|
||||
|
||||
const preview = document.getElementById('avatarPreview');
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
if (input.files && input.files[0]) {
|
||||
const roleSelect = document.getElementById('adminRole');
|
||||
|
||||
const reader = new FileReader();
|
||||
const superAdminRole =
|
||||
<?php echo json_encode(\App\Enums\Admin\AdminRole::SUPERADMIN->value, 15, 512) ?>;
|
||||
|
||||
reader.onload = function (e) {
|
||||
preview.style.backgroundImage =
|
||||
`url('${e.target.result}')`;
|
||||
};
|
||||
const manageAdminsPermission =
|
||||
<?php echo json_encode(\App\Enums\Admin\AdminPermission::MANAGE_ADMINS->value, 15, 512) ?>;
|
||||
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
|
||||
function handleAdminPermissions() {
|
||||
|
||||
const isSuperAdmin =
|
||||
roleSelect.value === superAdminRole;
|
||||
|
||||
|
||||
document
|
||||
.querySelectorAll('.permission-checkbox')
|
||||
.forEach(function (checkbox) {
|
||||
|
||||
if (
|
||||
checkbox.dataset.permission ===
|
||||
manageAdminsPermission
|
||||
) {
|
||||
|
||||
if (!isSuperAdmin) {
|
||||
|
||||
checkbox.checked = false;
|
||||
checkbox.disabled = true;
|
||||
|
||||
} else {
|
||||
|
||||
checkbox.disabled = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
roleSelect.addEventListener(
|
||||
'change',
|
||||
handleAdminPermissions
|
||||
);
|
||||
|
||||
|
||||
handleAdminPermissions();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php $__env->stopPush(); ?>
|
||||
|
||||
<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\ASUS\Desktop\airline-agency\resources\views/admin/admins/create.blade.php ENDPATH**/ ?>
|
||||
Reference in New Issue
Block a user