119 lines
3.9 KiB
PHP
119 lines
3.9 KiB
PHP
<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;
|
|
|
|
$__newAttributes = [];
|
|
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames(([
|
|
'id' => 'lfm-image',
|
|
'name' => 'logo',
|
|
'label' => 'Select Image',
|
|
'multiple' => 'true',
|
|
'data' => null,
|
|
'editable' => false,
|
|
]));
|
|
|
|
foreach ($attributes->all() as $__key => $__value) {
|
|
if (in_array($__key, $__propNames)) {
|
|
$$__key = $$__key ?? $__value;
|
|
} else {
|
|
$__newAttributes[$__key] = $__value;
|
|
}
|
|
}
|
|
|
|
$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);
|
|
|
|
unset($__propNames);
|
|
unset($__newAttributes);
|
|
|
|
foreach (array_filter(([
|
|
'id' => 'lfm-image',
|
|
'name' => 'logo',
|
|
'label' => 'Select Image',
|
|
'multiple' => 'true',
|
|
'data' => null,
|
|
'editable' => false,
|
|
]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
|
|
$$__key = $$__key ?? $__value;
|
|
}
|
|
|
|
$__defined_vars = get_defined_vars();
|
|
|
|
foreach ($attributes->all() as $__key => $__value) {
|
|
if (array_key_exists($__key, $__defined_vars)) unset($$__key);
|
|
}
|
|
|
|
unset($__defined_vars); ?>
|
|
|
|
<div class="upload__box">
|
|
<div class="<?php echo e($id); ?>-upload__img-wrap row">
|
|
</div>
|
|
|
|
<input id="<?php echo e($id); ?>" type="text" name="<?php echo e($name); ?>" value="<?php echo e($data); ?>"
|
|
class="form-control" readonly />
|
|
|
|
<div class="input-group mt-1">
|
|
<span class="input-group-btn">
|
|
<a href="javascript:void(0)" id="<?php echo e($id); ?>-input" data-input="<?php echo e($id); ?>"
|
|
class="link-primary link-opacity-75-hover link-offset-2">
|
|
<i class="ri-image-add-line me-1"></i> <?php echo e($label); ?>
|
|
|
|
</a>
|
|
</span>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<?php $__env->startPush('js'); ?>
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
let imgArray = [];
|
|
let eventListener = "<?php echo e($id); ?>";
|
|
let isMultiple = "<?php echo e($multiple); ?>";
|
|
let isEditable = "<?php echo e($editable); ?>";
|
|
let data = "<?php echo e($data); ?>";
|
|
|
|
const prefix = `${app_url}/laravel-filemanager`;
|
|
$(`#${eventListener}-input`).filemanager('file', {
|
|
prefix: prefix
|
|
});
|
|
|
|
$(document).on('change', `#${eventListener}`, function() {
|
|
const value = $(this).val();
|
|
|
|
imgArray = (isMultiple == true) ? value.split(',') : [value.split(',').pop()];
|
|
let imageUrl = imgArray.join(',');
|
|
$(`#${eventListener}`).val(imageUrl);
|
|
$(`.${eventListener}-upload__img-wrap`).empty();
|
|
|
|
$.each(imgArray, function(index, item) {
|
|
let html = `<div class='upload__img-box col-sm-auto'>
|
|
<div style='background-image: url("${app_url}/${item}")' class='img-bg'>
|
|
<div id="${eventListener}-img-close" data-file="${item}" class='upload__img-close'></div>
|
|
</div>
|
|
</div>`;
|
|
$(`.${eventListener}-upload__img-wrap`).append(html);
|
|
})
|
|
});
|
|
|
|
$(document).on('click', `#${eventListener}-img-close`, function(e) {
|
|
const file = $(this).data("file");
|
|
|
|
for (let i = 0; i < imgArray.length; i++) {
|
|
if (imgArray[i] == file) {
|
|
imgArray.splice(i, 1);
|
|
break;
|
|
}
|
|
}
|
|
let imageUrl = imgArray.join(',');
|
|
$(`#${eventListener}`).val(imageUrl);
|
|
$(this).parent().parent().remove();
|
|
});
|
|
|
|
if (isEditable && data) {
|
|
$(`#${eventListener}`).trigger('change');
|
|
}
|
|
|
|
});
|
|
</script>
|
|
<?php $__env->stopPush(); ?>
|
|
<?php /**PATH D:\installed\xampp\htdocs\bib\Consultancy-CCMS\resources\views/components/image-input.blade.php ENDPATH**/ ?>
|