@extends('admin.layouts.container')

@section('content')
<div class="side-title">
    <h3>{{$head ?? '' }}</h3>
</div>

<div class="border-item">
    <form class="form-row" method="post" action="{{ $action }}" enctype="multipart/form-data">
        @if($photoGallery ?? ''  && $photoGallery->id)
            @method('PUT')
        @endif
        @csrf

        @foreach($languages as $language)
            <?php
            $GalleryTitle = explode('@@', $photoGallery[$language->local]->title ?? '');
            $GalleryDescription = explode('@@', $photoGallery[$language->local]->description ?? '');
            ?>
        <div class="form-group col-lg-6">
            <label>{{ meta('title_1', $language->local) ?? __('photoGalleries.title_1') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('title_1_'.$language->local) ? 'is-invalid' : '' }}" name="title_1_{{ $language->local }}" placeholder="{{ meta('title_1', $language->local) ?? __('photoGalleries.title_1') }}" value='{{ old("title_1_{$language->local}", $GalleryTitle[0] ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('title', $language->local) ?? __('photoGalleries.title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('title_2_'.$language->local) ? 'is-invalid' : '' }}" name="title_2_{{ $language->local }}" placeholder="{{ meta('title_2', $language->local) ?? __('photoGalleries.title_2') }}" value='{{ old("title_2_{$language->local}", $GalleryTitle[1] ?? "") }}'/>
        </div>
        <div class="form-group col-lg-12">
            <label>{{ meta('description_1', $language->local) ?? __('photoGalleries.description_1') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <textarea name="description_1_{{ $language->local }}" class="form-control my-editor {{ $errors->has('description_1_'.$language->local) ? 'is-invalid' : '' }}" placeholder="{{ meta('description_1', $language->local) ?? __('photoGalleries.description_1') }}">{{ old("description_1_{$language->local}", $GalleryDescription[0] ?? "") }}</textarea>
        </div>
        <div class="form-group col-lg-12">
            <label>{{ meta('description_2', $language->local) ?? __('photoGalleries.description_2') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <textarea name="description_2_{{ $language->local }}" class="form-control my-editor {{ $errors->has('description_2_'.$language->local) ? 'is-invalid' : '' }}" placeholder="{{ meta('description_2', $language->local) ?? __('photoGalleries.description_2') }}">{{ old("description_2_{$language->local}", $GalleryDescription[1] ?? "") }}</textarea>
        </div>

        @endforeach
        {{--Start image_1 container--}}
        <div class="form-group col-lg-6">
            <label>{{ meta('image_1', getCurrentLocale()) ?? __('photoGalleries.image_1') }} </label>
            <input id="image_1_thumbnail" class="image_1_thumbnail" type="hidden" name="image_1" value="{{old("image_1", $photoGallery->image[0] ?? "")}}"/>

            <div class="photos image_1_main_photo {{ old('image_1', $photoGallery->image[0] ?? '') ? ' wow fadeInUp' : 'hide' }}">
                <div class="col-lg-12">
                    <div class="items">
                        <div class="img">
                            <a href="#" id="lfm" data-input=".image_1_thumbnail" data-preview=".image_1_holder" class="lfm" data-hide=".image_1_pick_button">
                                <img src="{{asset(old('image_1', $photoGallery->image[0] ?? ''))}} "  id="image_1_holder" class="image_1_holder"/>
                            </a>
                        </div>
                        <a href="#" class="showHide resetImage close" data-empty=".image_1_thumbnail" data-hide=".image_1_main_photo" data-show=".image_1_pick_button"><i class="fas fa-times"></i></a>
                    </div>
                </div>
            </div>

            <div class="clearfix"></div>
            <span class="input-group-btn image_1_pick_button {{ old('image_1', $photoGallery->image[0] ?? '') ? 'hide' : '' }} ">
            <a id="lfm" data-input=".image_1_thumbnail" data-preview=".image_1_holder" data-show=".image_1_main_photo" data-hide=".image_1_pick_button" class="lfm btn btn-primary text-light">
                <i class="fas fa-camera-retro"></i> Choose
            </a>
        </span>
        </div>
        {{--End image_1 container--}}

            {{--Start image_2 container--}}
            <div class="form-group col-lg-6">
                <label>{{ meta('image_2', getCurrentLocale()) ?? __('photoGalleries.image_2') }} </label>
                <input id="image_2_thumbnail" class="image_2_thumbnail" type="hidden" name="image_2" value="{{old("image_2", $photoGallery->image[1] ?? "")}}"/>

                <div class="photos image_2_main_photo {{ old('image_2', $photoGallery->image[1] ?? '') ? ' wow fadeInUp' : 'hide' }}">
                    <div class="col-lg-12">
                        <div class="items">
                            <div class="img">
                                <a href="#" id="lfm" data-input=".image_2_thumbnail" data-preview=".image_2_holder" class="lfm" data-hide=".pick_button">
                                    <img src="{{asset(old('image_2', $photoGallery->image[1] ?? ''))}} "  id="image_2_holder" class="image_2_holder"/>
                                </a>
                            </div>
                            <a href="#" class="showHide resetImage close" data-empty=".image_2_thumbnail" data-hide=".image_2_main_photo" data-show=".pick_button"><i class="fas fa-times"></i></a>
                        </div>
                    </div>
                </div>

                <div class="clearfix"></div>
                <span class="input-group-btn pick_button {{ old('image_2', $photoGallery->image[1] ?? '') ? 'hide' : '' }} ">
            <a id="lfm" data-input=".image_2_thumbnail" data-preview=".image_2_holder" data-show=".image_2_main_photo" data-hide=".pick_button" class="lfm btn btn-primary text-light">
                <i class="fas fa-camera-retro"></i> Choose
            </a>
        </span>
            </div>
            {{--End image_2 container--}}

            <div class="text-center mt-5 col-12">
            <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
        </div>
    </form>
</div>

@endsection

@section('inner_js')
    <!-- Editor JS files -->
        <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>
{{--    <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>--}}
    <script>
        var route_prefix = "{{ url(config('lfm.prefix')) }}";
        var url = "{{url('/')}}/",
        currentLanguage = "{{getCurrentLocale()}}",
        inputName = null;
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>

@endsection



