@php $files = config('cabinet.other-files.files') ?? []; $iconMap = [ 'pdf' => 'fa-file-pdf', // Иконка для PDF 'doc' => 'fa-file-word', // Иконка для Word 'docx' => 'fa-file-word', 'xls' => 'fa-file-excel', // Иконка для Excel 'xlsx' => 'fa-file-excel', 'txt' => 'fa-file-alt', // Иконка для текстовых файлов 'jpg' => 'fa-file-image', // Иконка для изображений 'jpeg' => 'fa-file-image', 'png' => 'fa-file-image', 'gif' => 'fa-file-image', 'zip' => 'fa-file-archive', // Иконка для архивов 'rar' => 'fa-file-archive', 'default' => 'fa-file', // Иконка по умолчанию ]; @endphp @foreach($files as $k => $file) @php $extension = pathinfo($file, PATHINFO_EXTENSION); $iconClass = $iconMap[$extension] ?? $iconMap['default']; // Определяем класс иконки @endphp
{!! \MoonShine\Fields\Text::make('Ссылка')->copy()->readonly()->default(asset($file)) !!} {!! \MoonShine\ActionButtons\ActionButton::make( '', )->customAttributes(['style' => 'width: 100%!important']) ->withConfirm( formBuilder: fn() => \MoonShine\Components\FormBuilder::make( fields: [ \MoonShine\Fields\Hidden::make('id')->customAttributes(['value' => $k]) ])->asyncMethod('file_remove', events: ['reload']) )->icon('heroicons.x-mark') !!}
@if (in_array($extension, ['jpg', 'jpeg', 'png', 'gif'])) # @else @endif
@endforeach