71 lines
3 KiB
PHP
71 lines
3 KiB
PHP
{{-- blade-formatter-disable --}}
|
|
{{--
|
|
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
|
|
|
|
$id || The id of the input tag. || string || REQUIRED ||
|
|
$name || The name of the input tag. || string || REQUIRED ||
|
|
$helper || The helper of the input. || string || REQUIRED ||
|
|
$label || The text displayed as a label. || string || OPTIONNAL || null
|
|
$required || Is the field required ? || boolean || OPTIONNAL || false
|
|
$value || The default value of the input. || string || OPTIONNAL || ''
|
|
$file || The accepted files extensions. || string || OPTIONNAL || '.pdf'
|
|
$model || The model we're creating/editing || Model class || OPTIONNAL || null
|
|
--}}
|
|
|
|
@if(!empty($label))
|
|
<label for="{{ $id }}" class="col-form-label">
|
|
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
|
|
</label>
|
|
@endif
|
|
<div class="input-group">
|
|
<input name="{{ $name }}"
|
|
type="file"
|
|
value="{{ old($name, $model->{$name} ?? $value ?? '') }}"
|
|
class="form-control @if($errors->has($name)) is-invalid @endif"
|
|
id="{{ $id }}"
|
|
aria-describedby="{{ $id }}Help"
|
|
accept="{{ $file ?? '.pdf' }}"
|
|
@if(!empty($required))
|
|
required
|
|
@endif>
|
|
@if (!empty($model->{$name}))
|
|
<a class="btn btn-warning"
|
|
href="/{{ $model->{$name} }}"
|
|
target="_blank"
|
|
title="{{ __("Visualiser votre fichier :name", ['name' => basename($model->{$name})]) }}"
|
|
data-bs-toggle="tooltip">
|
|
{{ basename($model->{$name}) }}
|
|
</a>
|
|
@php
|
|
$removeBtnId = 'remove-btn-id-' . uniqid();
|
|
@endphp
|
|
<button class="btn btn-danger" id="{{ $removeBtnId }}" data-bs-toggle="tooltip"
|
|
title="{{ __('Supprimer le fichier :type', ['type' => $file ?? '.pdf']) }}">
|
|
<i class="fa fa-trash"></i>
|
|
</button>
|
|
@push('scripts')
|
|
<script nonce="{{ $nonce }}">
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const removeBtn = document.getElementById('{{ $removeBtnId }}'),
|
|
input = removeBtn.parentElement.querySelector('input'),
|
|
link = removeBtn.parentElement.querySelector('a');
|
|
input.addEventListener('change', () => {
|
|
removeBtn.classList.remove('d-none');
|
|
link.classList.add('d-none');
|
|
});
|
|
removeBtn.addEventListener('click', (e) => {
|
|
e.preventDefault();
|
|
input.value = "";
|
|
removeBtn.classList.add('d-none');
|
|
link.classList.add('d-none');
|
|
});
|
|
});
|
|
</script>
|
|
@endpush
|
|
@endif
|
|
</div>
|
|
@include('modules.input-error', [
|
|
'inputName' => $name,
|
|
'helperId' => "{$id}Help",
|
|
'helper' => $helper
|
|
])
|