@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 }}">
        @if($photoGallery ?? ''  && $photoGallery->id ?? '')
            @method('PUT')
        @endif
        @csrf

        @foreach(languages() as $language)
            <div class="form-group col-lg-6">
                <label>{{ meta('name', $language->local) ?? __('photoCategories.title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                <input type="text" class="form-control {{ $errors->has('name_'.$language->local) ? 'is-invalid' : '' }}" name="name_{{ $language->local }}" placeholder="{{ meta('name', $language->local) ?? __('photoCategories.title') }}" value='{{ old("name_{$language->local}", $photoGallery[$language->local]->name ?? "") }}'/>
            </div>
        @endforeach

        <div class="border-item photos col-md-12">
            <div class="row">
                @if ($photoGallery ?? false)
                    @foreach ($photoGallery['photos'] as $photo)
                        <div class="col-lg-4">
                            <div class="items">
                                <div class="img">
                                    <a href="{{ asset($photo->image ?? '')}}" data-fancybox="gallery"><img src="{{ asset($photo->image ?? '')}}" alt=""></a>
                                </div>
                                <div class="info d-none">
                                    <div class="img-title">
                                        <input type="hidden" name="images[]" value="{{ $photo->image ?? "" }}">
                                        <span class="preview"> </span>
                                    </div>
                                </div>
                                <a href="#" class="close"><i class="fas fa-times"></i></a>
                            </div>
                        </div>
                    @endforeach
                @endif
            </div>
            <div class="text-center">
                <input id="image_thumbnail" class="image_thumbnail" type="hidden"/>
                <div class="clearfix"></div>
                <span class="pick_button" id="add">
                    <a id="lfm" data-cache="photo_gallery" data-title="true" data-url="" data-width="" data-input=".image_thumbnail" data-preview=".image_holder" data-show="" data-hide="" class="lfm add">
                        {{meta('add_new_item', getCurrentLocale()) ?? 'Add New Item'}}
                    </a>
                </span>
            </div>
        </div>

        <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>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            imagePath = "{{asset('')}}";

    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
    <script src="{{ asset('assets/admin/js/photos.js') }}"></script>
@endsection
