Файловый менеджер - Редактировать - /home/clickysoft/public_html/travel-guru.clickysoft.net/resources/views/admin/pages/update.blade.php
Назад
@extends('admin.layouts.master') @section('title', 'Edit Page') @push('admin-styles') @endpush @section('content') <div class="container-xxl flex-grow-1 container-p-y"> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-8 col-xs-9 bhoechie-tab-container" style="background-color:white;"> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-10 bhoechie-tab"> <!-- Edit liveaboard Form --> <div class="bhoechie-tab-content active"> <div class="p-5 mb-4"> <h5 class="card-header">Edit Page</h5> <div class="card-body"> @php $urlRouteMapping = [ 'home*' => 'pages.home.update.data', 'our-team*' => 'pages.team.update.data', 'about-us*' => 'pages.aboutus.update.data', 'contact-us*' => 'pages.contactus.update.data', ]; $defaultRouteName = 'pages.aboutus.update.data'; $matchedRoute = collect($urlRouteMapping)->first(function ( $route, $pattern, ) use ($page) { return fnmatch($pattern, $page->url); }); // Use the matched route or the default route $routeName = $matchedRoute ?: $defaultRouteName; @endphp <form action="{{ route($routeName, $page->id) }}" method="POST" enctype="multipart/form-data"> @csrf @include('partials.alert') <div class="row"> <div class="col-md-12 mb-12"> <label class="form-label">Title <i class="fa small-font text-danger" aria-hidden="true"></i> </label> <input type="text" class="form-control" name="name" value="{{ old('name', $page->name) }}" placeholder="Enter Title" disabled /> </div> </div> @if ($page->url === 'home') <div class="row mt-3"> <div class="mb-5"> <label class="form-label">Banner Image</label> <input class="form-control" type="file" name="image" id="formFile" accept="image/*" onchange="previewImage()"> </div> @if ($page->hasMedia('image')) <img id="banner-frame" class="img-fluid img-thumbnail" src="{{ $page->getFirstMediaUrl('image') }}" style="width: 300px;"> @else <img id="banner-frame" class="img-fluid img-thumbnail" style="display: none; width: 300px;"> @endif </div> @endif @if ($page->url === 'our-team') <div class="row p-3 "> <h5 class="card-header mb-3">Photo & Video gallery</h5> <div class="card-body"> <div class="col-12"> <div class="card"> <div class="card-body"> <div class="row mt-3"> <div class="col-md-12 mb-5"> <div class="dropzone needsclick" id="dropzone-multi" data-destination-id="{{ $page->id }}"> <div class="dz-message needsclick"> Drop files here or click to upload </div> <!-- Add the input file field --> <input type="file" name="file" style="display: none;"> </div> </div> </div> <div class="row"> <div class="col-md-12 mb-2"> @include('admin.pages.file_list') </div> </div> </div> </div> </div> </div> </div> @endif <div class="row mt-5"> <h5 class="card-header">Section</h5> </div> <div class="row mt-3"> <div class="testimonial-div-clone"> <input id="total-sections" type="hidden" value="{{ count($page->sections) }}" /> @if (count($page->sections) > 0) @foreach ($page->sections as $section) <div class="row mt-3"> <div class="col-md-12 mb-3"> @if ($section->id == 4 || $section->id == 5) <input type="hidden" name="section_title[{{ $section->id }}]" value="{{ $section->title }}" /> @else <label class="form-label">Name <i class="fa small-font text-danger" aria-hidden="true"></i> </label> <input type="text" class="form-control" name="section_title[{{ $section->id }}]" value="{{ $section->title }}" /> @endif <input type="hidden" name="section_id[{{ $section->id }}]" value="{{ $section->id }}" /> </div> <div class="col-md-12 mb-3"> @if ($section->id == 4 || $section->id == 5) <input type="hidden" name="section_description[{{ $section->id }}]" value="{{ $section->description }}" /> @else <label class="form-label">Description <i class="fa small-font text-danger" aria-hidden="true"></i> </label> <textarea class="form-control" name="section_description[{{ $section->id }}]">{{ $section->description }}</textarea> @endif </div> @if ($section->id != 1 && $section->id != 2 && $section->id != 3) <div class="row mt-3"> <div class="mb-5"> <label class="form-label">File</label> <input class="form-control" type="file" name="section_file[{{ $section->id }}]" id="formFile-{{ $section->id }}" onchange="preview(this)"> </div> <div class="preview-container"> @if ($section->hasMedia('files')) @php $media = $section->getFirstMedia( 'files', ); $mediaType = explode( '/', $media->mime_type, )[0]; @endphp @if ($mediaType === 'image') <img class="frame img-fluid img-thumbnail" id="preview-{{ $section->id }}" src="{{ $section->getFirstMediaUrl('files', 'image') }}" alt="Preview Image" style="width:200px"> @elseif ($mediaType === 'video') <video class="frame" id="video-preview-{{ $section->id }}" src="{{ $section->getFirstMediaUrl('files', 'video') }}" controls style="width:200px"></video> @endif @else <img class="frame img-fluid img-thumbnail" id="preview-{{ $section->id }}" src="" alt="Preview Image" style="display: none;width:200px" /> <video class="frame" id="video-preview-{{ $section->id }}" src="" controls style="display: none;width:200px"></video> @endif </div> </div> @endif </div> @endforeach @else <div class="row mt-3"> <div class="div-clone"> <div class="row mt-3"> <div class="col-md-12 mb-3"> <label class="form-label">Title <i class="fa small-font text-danger" aria-hidden="true"></i> </label> <input type="text" class="form-control" name="section_title[]" id="name-input" value=""> </div> <div class="col-md-12 mb-3"> <label class="form-label">Description <i class="fa small-font text-danger" aria-hidden="true"></i> </label> <textarea type="text" class="form-control" name="section_description[]" id="name-input" value=""></textarea> </div> <div class="row mt-3"> <div class="mb-5"> <label class="form-label">File</label> <input class="form-control" type="file" name="section_file[]" id="formFile-0" onchange="preview(this)" accept="image/*,video/*"> </div> <div class="preview-container"> <img class="frame img-fluid img-thumbnail" id="preview-0" src="" alt="Preview Image" style="display: none;width:200px" /> <video class="frame" id="video-preview-0" src="" controls style="display: none;width:200px"></video> </div> </div> <div class="col-md-12 mt-4"> {{-- <button type="button" class="btn btn-primary" onclick="addTestimonial(this)"><i class="fa fa-plus"></i></button> --}} <!-- You may omit the remove button for the first row --> </div> </div> </div> </div> @endif </div> </div> <div class="row mt-3"> <div class="col-md-12"> <button type="submit" class="btn btn-primary" onclick="showLoader()">Update</button> </div> </div> </form> </div> </div> </div> </div> </div> </div> </div> </div> @push('admin-scripts') <script> const totalSections = parseInt($('#total-sections').val()); let testimonialCounter = totalSections; function addTestimonial(input) { testimonialCounter++; const nameInputId = `name-input-${testimonialCounter}`; const descriptionInputId = `description-input-${testimonialCounter}`; const fileInputId = `formFile-${testimonialCounter}`; $('.testimonial-div-clone').append(` <div class="row mt-3"> <div class="col-md-12 mb-3"> <label class="form-label">Name <i class="fa small-font text-danger" aria-hidden="true"></i> </label> <input type="text" class="form-control" name="section_title[]" id="${nameInputId}" value=""> </div> <div class="col-md-12 mb-3"> <label class="form-label">Description <i class="fa small-font text-danger" aria-hidden="true"></i> </label> <textarea type="text" class="form-control" name="section_description[]" id="${descriptionInputId}" value=""></textarea> </div> <div class="row mt-3"> <div class="mb-5"> <label class="form-label">File</label> <input class="form-control" type="file" name="section_file[]" id="${fileInputId}" onchange="preview(this)" accept="image/*,video/*"> </div> <div class="preview-container"> <img class="frame img-fluid img-thumbnail" id="preview-${testimonialCounter}" src="" alt="Preview Image" style="display: none; width:200px" /> <video class="frame" id="video-preview-${testimonialCounter}" src="" controls style="display: none; width:200px"></video> </div> </div> <div class="col-md-12 mt-4"> <button type="button" class="btn btn-primary" onclick="addTestimonial(this)"><i class="fa fa-plus"></i></button> <button type="button" class="btn btn-danger" onclick="removeTestimonial(this)"><i class="fa fa-minus"></i></button> </div> </div> `); } function removeTestimonial(input) { $(input).parent().parent().remove(); } function preview(input) { const fileInput = input; const file = fileInput.files[0]; const previewId = $(input).closest('.row').find('.frame').attr('id'); const videoPreviewId = $(input).closest('.row').find('video').attr('id'); const imgElement = $(`#${previewId}`); const videoElement = $(`#${videoPreviewId}`); if (file) { const reader = new FileReader(); reader.onload = function(e) { const fileType = file.type.split('/')[0]; // Get the file type (image or video) if (fileType === 'image') { imgElement.attr('src', e.target.result); imgElement.show(); videoElement.hide(); } else if (fileType === 'video') { videoElement.attr('src', e.target.result); videoElement.show(); imgElement.hide(); } else { // Handle other file types if needed imgElement.hide(); videoElement.hide(); } }; reader.readAsDataURL(file); } else { imgElement.hide(); videoElement.hide(); } } </script> <script> Dropzone.autoDiscover = false; $(document).ready(function() { const previewTemplate = `<div class="dz-preview dz-file-preview"> <div class="dz-details"> <div class="dz-thumbnail"> <img data-dz-thumbnail> <span class="dz-nopreview">No preview</span> <div class="dz-success-mark"></div> <div class="dz-error-mark"></div> <div class="dz-error-message"><span data-dz-errormessage></span></div> <div class="progress"> <div class="progress-bar progress-bar-primary" role="progressbar" aria-valuemin="0" aria-valuemax="100" data-dz-uploadprogress></div> </div> </div> <div class="dz-filename" data-dz-name></div> <div class="dz-size" data-dz-size></div> </div> </div>`; // Configuration options for Dropzone var id = $('#dropzone-multi').data('destination-id'); var url = "{{ route('pages.upload.gallery', ':id') }}"; url = url.replace(':id', id); var dropzoneConfig = { previewTemplate: previewTemplate, headers: { 'X-CSRF-TOKEN': "{{ csrf_token() }}", }, parallelUploads: 1, maxFilesize: 20, // addRemoveLinks: true, maxFiles: 50, url: url, method: "post", autoProcessQueue: true, uploadMultiple: true, acceptedFiles: 'image/jpeg,image/png,image/jpg,video/*', }; var myDropzone = new Dropzone("#dropzone-multi", dropzoneConfig); myDropzone.on("success", function(file, response) { if (response.html) { // Prepend the new rows to the table body $("#file-list").prepend(response.html); } }); }); </script> <script> $(document).ready(function() { $(document).on('click', '.delete-media-item', function() { const button = $(this); const row = button.closest('tr'); const mediaId = row.data('media-id'); Swal.fire({ title: 'Delete Media Item?', text: 'Are you sure you want to delete this media item?', icon: 'warning', showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#3085d6', confirmButtonText: 'Yes, delete it!', cancelButtonText: 'Cancel' }).then((result) => { if (result.isConfirmed) { // User confirmed, proceed with deletion deleteMediaItem(mediaId, row); } }); }); // Function to delete media item via AJAX function deleteMediaItem(mediaId, row) { // Send an AJAX request to delete the media item const deleteUrl = "{{ route('pages.update.delete.media.gallery', ['id' => ':mediaId']) }}" .replace(':mediaId', mediaId); $.ajax({ url: deleteUrl, type: 'DELETE', headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, success: function(data) { if (data.message) { // Media item deleted successfully row.remove(); Swal.fire('Deleted!', data.message, 'success'); } else { // Handle the case where deletion failed Swal.fire('Error', data.error, 'error'); } }, error: function(xhr, status, error) { // Handle any errors that occur during the request console.error('Error:', error); Swal.fire('Error', 'An error occurred while deleting the media item.', 'error'); } }); } }); </script> <script> function previewVideo() { var fileInput = document.getElementById('formFile'); // Corrected ID here var videoElement = document.getElementById('banner-frame'); if (fileInput.files && fileInput.files[0]) { var reader = new FileReader(); reader.onload = function(e) { videoElement.src = e.target.result; videoElement.style.display = 'block'; // Show the video element }; reader.readAsDataURL(fileInput.files[0]); } else { videoElement.style.display = 'none'; // Hide the video element if no file is selected } } </script> @endpush @endsection
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка