HEX
Server: LiteSpeed
System: Linux php-prod-3.spaceapp.ru 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: sarli3128 (1010)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/marketing.cfbon.ru/public_html/resources/views/site/photo-gallery/edit.blade.php
@extends('layouts.main')

@section('return_btn_url') @include('layouts.return-btn', ['routeName' => 'site.photo-gallery.index']) @endsection

@section('title', 'Редактировать фото')

@section('content')
    <div class="container mt-3 ms-2">
        <form action="{{ route('site.photo-gallery.update', $image->id) }}" method="post" enctype="multipart/form-data">
            @csrf
            @method('PATCH')
            <div class="row d-flex">
                <div class="col-md-6">
                    <div class="mb-3">
                        <label for="img" class="form-label">Выберите изображение</label>
                        <input accept="image/*" type="file" class="form-control @error('img') is-invalid @enderror" name="img" id="img">
                        @error('img')<div class="invalid-feedback">{{ $message }}</div>@enderror
                    </div>

                    <div class="mb-3 mt-2 switch-wrapper">
                        <label class="switch-label">
                            <input type="checkbox" name="is_active"
                                   {{ old('is_active', $image->is_active ? 'on' : '') == 'on' ? 'checked' : '' }}
                                   class="switch-checkbox @error('is_active') is-invalid @enderror">
                            <span class="switch-slider"></span>
                            <span class="switch-text">Активно</span>
                        </label>

                        @error('is_active')<div class="invalid-feedback">{{ $message }}</div>@enderror
                    </div>

                    <button type="submit" class="btn btn-danger w-25">Сохранить</button>
                </div>
                <div class="col-md-6">
                    <div class="border rounded p-3 bg-light">
                        <div id="preview" class="text-center d-flex flex-column align-items-center justify-content-center">
                            <img src="{{ $image->img_url }}" alt="Предпросмотр картинки" class="img-fluid rounded" style="max-height: 300px;" id="imagePreview">
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
@endsection
@section('scripts')
    @parent
    <script>
        document.getElementById('img').addEventListener('change', function () {
            const file = this.files[0];
            const preview = document.getElementById('imagePreview');

            if (file) {
                const reader = new FileReader();
                reader.onload = function (e) {
                    preview.src = e.target.result;
                    preview.style.display = 'block';
                };
                reader.readAsDataURL(file);
            } else {
                preview.src = '';
                preview.style.display = 'none';
            }
        });
    </script>
@endsection