edit-flot.blade.php 9.52 KB
@extends('layout.frontend', ['title' => 'Редактирование флота - РекаМоре'])

@section('scripts')
    <script src="https://cdn.ckeditor.com/ckeditor5/23.0.0/classic/ckeditor.js"></script>
    <script>
        $(function() {
            $('form.cabinet__add [type="file"][name="image"]').change(function (event) {
                const file = event.target.files[0];

                if (file) {
                    var img_wrap = $('.flot-image-wrap');
                    var img = $('<img id="flot-img" src="#"/>');
                    const reader = new FileReader();

                    reader.onload = function(e) {
                        img.attr('src', e.target.result);
                        img_wrap.find('img').remove();
                        img_wrap.append(img);
                        $('.no-img-svg').remove();
                    };

                    reader.readAsDataURL(file);
                }
            });
        });

        ClassicEditor
            .create( document.querySelector( '#txtarea' ) )
            .catch( error => {
                console.error( error );
            } );
    </script>
@endsection
@section('content')
    <section class="cabinet">
        <div class="container">
            <ul class="breadcrumbs cabinet__breadcrumbs">
                <li><a href="{{ route('index') }}">Главная</a></li>
                <li><b>Личный кабинет</b></li>
            </ul>
            <div class="cabinet__wrapper">
                <div class="cabinet__side">
                    <div class="cabinet__side-toper">
                        @include('employers.emblema')
                    </div>

                    @include('employers.menu', ['item' => 12])

                </div>
                <div class="cabinet__body">
                    @include('messages_error')

                    <div class="cabinet__body-item">
                        <div class="cabinet__descr">
                            <h2 class="title cabinet__title">Редактирование флота</h2>
                        </div>

                        <form action="{{ route('employer.update_flot_save', ['Flot' => $Flot->id]) }}" enctype="multipart/form-data" method="POST" class="cabinet__add">
                            @csrf
                            <label class="cabinet__add-pic" style="vertical-align: top">
                                <input type="file" name="image" id="image">
                                @error('image')
                                <span class="text-xs text-red-600">
                                   {{ $message }}
                                </span>
                                @enderror
                                <input type="hidden" name="employer_id" id="employer_id" value="{{ $Employer->id }}"/>
                                <div class="flot-image-wrap">
                                    @if (!empty($Flot->image))
                                        <img id="flot-img" src="{{ asset(Storage::url($Flot->image)) }}" alt="{{ $Flot->name }}">
                                    @endif
                                </div>
                                @if (empty($Flot->image))
                                    <svg class="no-img-svg">
                                        <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use>
                                    </svg>
                                @endif
                                <span>
                                        <svg>
                                            <use xlink:href="{{ asset('images/sprite.svg#plus') }}"></use>
                                        </svg>
                                        Загрузить фото
                                </span>
                            </label>

                            <div class="cabinet__add-body">
                                <div class="form-group">
                                    <label class="form-group__label">Название</label>
                                    <div class="form-group__item">
                                        <input type="text" name="name" id="flot_name" class="input" value="{{ old('name') ?? $Flot->name ?? '' }}" placeholder="Корабль №000001" required>
                                        @error('name')
                                        <span class="text-xs text-red-600">
                                            {{ $message }}
                                        </span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="form-group" style="display:none">
                                    <label class="form-group__label">Описание</label>
                                    <div class="form-group__item">
                                        <input type="text" name="text" id="flot_text" class="input" placeholder="Это судно находится..." value="{{ old('text') ?? $Flot->text ?? '' }}">
                                        @error('text')
                                        <span class="text-xs text-red-600">
                                            {{ $message }}
                                        </span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="form-group" style="display:none">
                                    <label class="form-group__label">Регион</label>
                                    <div class="form-group__item">
                                        <input type="text" name="region" id="region" class="input" placeholder="Мурманск" value="{{ old('region') ?? $Flot->region ?? '' }}">
                                        @error('region')
                                        <span class="text-xs text-red-600">
                                          {{ $message }}
                                        </span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="form-group" style="display:none">
                                    <label class="form-group__label">Мощность</label>
                                    <div class="form-group__item">
                                        <input type="text" name="power" id="flot_power" class="input" placeholder="Dw 40000 9000Kw" value="{{ old('power') ?? $Flot->power ?? '' }}">
                                        @error('power')
                                        <span class="text-xs text-red-600">
                                            {{ $message }}
                                        </span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="form-group__label">DWT</label>
                                    <div class="form-group__item">
                                        <input type="text" name="DWT" id="flot_DWT" class="input" placeholder="4000 т" value="{{ old('DWT') ?? $Flot->DWT ?? '' }}">
                                        @error('DWT')
                                        <span class="text-xs text-red-600">
                                            {{ $message }}
                                        </span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="form-group__label">Мощность ГД (кВт)</label>
                                    <div class="form-group__item">
                                        <input type="text" name="POWER_GD" id="flot_POWER_GD" class="input" placeholder="14000 кВт" value="{{ old('POWER_GD') ?? $Flot->POWER_GD ?? '' }}">
                                        @error('POWER_GD')
                                        <span class="text-xs text-red-600">
                                            {{ $message }}
                                        </span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="form-group" style="">
                                    <label class="form-group__label">IMO</label>
                                    <div class="form-group__item">
                                        <input type="text" name="IMO" id="flot_IMO" class="input" placeholder="8814275" value="{{ old('IMO') ?? $Flot->IMO ?? '' }}">
                                        @error('IMO')
                                        <span class="text-xs text-red-600">
                                            {{ $message }}
                                        </span>
                                        @enderror
                                    </div>
                                </div>
                                <button type="submit" class="button" id="ajax_flot-" name="ajax_flot-">Сохранить флот</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </section>
    </div>
    <!-- END TOP WRAPPER -->
@endsection