/home/kueuepay/public_html/storage/framework/views/4a549f274c7fd53659724a2d046f581ca1a74e68.php
<?php if(isset($admin_roles)): ?>
    <?php if(admin_permission_by_name("admin.admins.admin.update")): ?>
        <div id="admin-edit" class="mfp-hide large">
            <div class="modal-data">
                <div class="modal-header">
                    <h5 class="modal-title"><?php echo e(__("Edit Admin")); ?></h5>
                </div>
                <div class="modal-form-data">
                    <form class="modal-form" method="POST" action="<?php echo e(setRoute('admin.admins.admin.update')); ?>" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field("PUT"); ?>
                        <input type="hidden" name="target" value="<?php echo e(old("target")); ?>">
                        <div class="row mb-10-none">
                            <div class="col-xl-12 col-lg-12 form-group">
                                <label for="countryFlag"><?php echo e(__("Profile Image")); ?></label>
                                <div class="col-12 col-sm-3 m-auto">
                                    <?php echo $__env->make('admin.components.form.input-file',[
                                        'label'             => false,
                                        'class'             => "file-holder m-auto",
                                        'name'              => "edit_image",
                                        'old_files_path'    => files_asset_path('admin-profile'),
                                        'old_files'         => old('old_image')
                                    ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                </div>
                            </div>
                            <div class="col-xl-6 col-lg-6 form-group">
                                <?php echo $__env->make('admin.components.form.input',[
                                    'label'         => __("First Name")."*",
                                    'name'          => "edit_firstname",
                                    'placeholder'   => __("First Name"),
                                    'value'         => old("edit_firstname"),  
                                ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                            </div>
                            <div class="col-xl-6 col-lg-6 form-group">
                                <?php echo $__env->make('admin.components.form.input',[
                                    'label'         => __("Last Name")."*",
                                    'name'          => "edit_lastname",
                                    'placeholder'   => __("Last Name"),
                                    'value'         => old("edit_lastname"),   
                                ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                            </div>
                            <div class="col-xl-6 col-lg-6 form-group">
                                <?php echo $__env->make('admin.components.form.input',[
                                    'label'         => __("username"),
                                    'name'          => "edit_username",
                                    'placeholder'   => __("username"),
                                    'value'         => old("edit_username"),       
                                ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                            </div>
                            <div class="col-xl-6 col-lg-6 form-group">
                                <?php echo $__env->make('admin.components.form.input',[
                                    'label'         => __("Email")."*",
                                    'name'          => "edit_email",
                                    'placeholder'   => __("Email"),
                                    'value'         => old("edit_email"),     
                                ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                            </div>
                            <div class="col-xl-6 col-lg-6 form-group">
                                <?php echo $__env->make('admin.components.form.input',[
                                    'label'         => __("Phone"),
                                    'name'          => "edit_phone",
                                    'placeholder'   => __("Phone"),
                                    'value'         => old("edit_phone"),
                                ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                            </div>
                            <div class="col-xl-6 col-lg-6 form-group role-select-wrp" data-admin-roles="<?php echo e(json_encode($admin_roles)); ?>">
                                <label><?php echo e(__("Role")); ?>*</label>
                                <select class="form--control select2-auto-tokenize" name="edit_role[]" data-old="<?php echo e(old("edit_role")); ?>" multiple data-placeholder="Select Role">
                                    <?php $__currentLoopData = $admin_roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($item->id); ?>"><?php echo e($item->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-xl-12 col-lg-12 form-group d-flex align-items-center justify-content-between mt-4">
                                <button type="button" class="btn btn--danger modal-close"><?php echo e(__("Cancel")); ?></button>
                                <button type="submit" class="btn btn--base"><?php echo e(__("Update")); ?></button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <?php $__env->startPush("script"); ?>
            <script>
                openModalWhenError("admin-edit","#admin-edit");
                $(document).on("click",".edit-modal-button",function(){
                    var oldData = JSON.parse($(this).parents("tr").attr("data-item"));
                    var editModal = $("#admin-edit");

                    editModal.find("form").first().find("input[name=target]").val(oldData.username);
                    editModal.find("input[name=edit_firstname]").val(oldData.firstname);
                    editModal.find("input[name=edit_lastname]").val(oldData.lastname);
                    editModal.find("input[name=edit_username]").val(oldData.username);
                    editModal.find("input[name=edit_email]").val(oldData.email);
                    editModal.find("input[name=edit_phone]").val(oldData.phone);
                    editModal.find("input[name=edit_image]").attr("data-preview-name",oldData.image);

                    var admin_roles = editModal.find(".role-select-wrp").attr("data-admin-roles");
                    admin_roles = JSON.parse(admin_roles);

                    var available_roles = oldData.roles.map(pluck("admin_role_id"));

                    var options = "";
                    $.each(admin_roles,function(index,item) {
                        console.log(available_roles);
                        if(available_roles.includes(item.id)) {
                            options += `<option value="${item.id}" selected>${item.name}</option>`;
                        }else {
                            options += `<option value="${item.id}">${item.name}</option>`;
                        }
                    });

                    var roleSelect = `<select class="form--control select2-auto-tokenize" name="edit_role[]" data-old="<?php echo e(old("edit_role")); ?>" multiple data-placeholder="Select Role">
                                        ${options}
                                    </select>`;

                    
                    editModal.find(".role-select-wrp select").remove();
                    editModal.find(".role-select-wrp .select2").remove();

                    editModal.find(".role-select-wrp").append(roleSelect);

                    editModal.find(".role-select-wrp select").select2();

                    fileHolderPreviewReInit("#admin-edit input[name=edit_image]");
                    openModalBySelector("#admin-edit");

                });
            </script>
        <?php $__env->stopPush(); ?>
    <?php endif; ?>
<?php endif; ?><?php /**PATH /home/kueuepay/public_html/resources/views/admin/components/modals/edit-admin.blade.php ENDPATH**/ ?>
Best Practice

Best Practices

To ensure a smooth integration process and optimal performance, follow these best practices:

  1. Use secure HTTPS connections for all API requests.
  2. Implement robust error handling to handle potential issues gracefully.
  3. Regularly update your integration to stay current with any API changes or enhancements.