<div class=" mt-3">
    <div class="row">
        <div class="col-12 col-md-6">
            <form action="/admin/settings/personalization/sliders" method="post">
                {{ csrf_field() }}
                 @if(!empty($slider))
                    <input type="hidden" name="item_id" value="{{ $slider->id }}">
                @endif


                @if(!empty(getGeneralSettings('content_translate')))
                    <div class="form-group">
                        <label class="input-label">{{ trans('auth.language') }}</label>
                        <select name="locale" class="form-control {{ !empty($slider) ? 'js-edit-content-locale' : '' }}">
                            @foreach($userLanguages as $lang => $language)
                                <option value="{{ $lang }}" @if(mb_strtolower(!empty($selectedLocale) ? $selectedLocale : app()->getLocale()) == mb_strtolower($lang)) selected @endif>{{ $language }}</option>
                            @endforeach
                        </select>
                        @error('locale')
                        <div class="invalid-feedback">
                            {{ $message }}
                        </div>
                        @enderror
                    </div>
                @else
                    <input type="hidden" name="locale" value="{{ getDefaultLocale() }}">
                @endif
                
                <div class="form-group">
                    <label>{{ trans('admin/main.title') }}</label>
                    <input type="text" name="title" value="{{ (!empty($slider) and !empty($slider->title)) ? $slider->title : old('title') }}" class="form-control @error('title') is-invalid @enderror"/>
                    @error('title')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                    @enderror
                </div>
                
                <div class="form-group">
                    <label>{{ trans('admin/main.button title') }}</label>
                    <input type="text" name="button_title" value="{{ (!empty($slider) and !empty($slider->button_title)) ? $slider->button_title : old('button_title') }}" class="form-control @error('button_title') is-invalid @enderror"/>
                    @error('title')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                    @enderror
                </div>
                
                <div class="form-group">
                    <label>{{ trans('admin/main.text') }}</label>
                    <input type="text" name="text" value="{{ (!empty($slider) and !empty($slider->text)) ? $slider->text : old('text') }}" class="form-control @error('text') is-invalid @enderror"/>
                    @error('title')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                    @enderror
                </div>

              
                <div class="form-group">
                    <label class="input-label">{{ trans('admin/main.image') }}</label>
                    <div class="input-group">
                        <div class="input-group-prepend">
                            <button type="button" class="input-group-text admin-file-manager" data-input="image" data-preview="holder">
                                <i class="fa fa-chevron-up"></i>
                            </button>
                        </div>
                        <input type="text" name="image" id="image" required value="{{ (!empty($slider) and !empty($slider->image)) ? $slider->image : old('image') }}" class="form-control"/>
                    </div>
                    @error('image')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                    @enderror
                </div>
                <div class="form-group">
                    <label>{{ trans('admin/main.Url') }}</label>
                    <input type="text" name="url" value="{{ (!empty($slider) and !empty($slider->url)) ? $slider->url : old('url') }}" class="form-control @error('url') is-invalid @enderror"/>
                    @error('url')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                    @enderror
                </div>

                <button type="submit" class="btn btn-success">{{ trans('admin/main.save_change') }}</button>
            </form>
        </div>
    </div>

    @if(!empty($sliders))
        <div class="table-responsive mt-5">
            <table class="table table-striped font-14">
                <tr>
                    <th>{{ trans('admin/main.title') }}</th>
                    <th>{{ trans('admin/main.Url') }}</th>
                    <th>{{ trans('admin/main.image') }}</th>
                    <th>{{ trans('admin/main.actions') }}</th>
                </tr>

                @foreach($sliders as $key => $row)
                    <tr>
                        <td>{{ $row->title }}</td>
                        <td>{{ $row->url }}</td>
                        <td>
                            <img class="img-fluid" src="{{asset(''.$row->image)}}">
                        </td>
                        <td>
                            @can('admin_settings_personalization')
                                <a href="/admin/settings/personalization/sliders/{{ $row->id }}/edit" class="btn-sm" data-toggle="tooltip" data-placement="top" title="{{ trans('admin/main.edit') }}">
                                    <i class="fa fa-edit"></i>
                                </a>
                            @endcan

                            @can('admin_settings_personalization')
                                @include('admin.includes.delete_button',['url' => '/admin/settings/personalization/sliders/'. $row->id .'/delete' , 'btnClass' => 'btn-sm'])
                            @endcan
                        </td>
                    </tr>
                @endforeach
            </table>
        </div>
    @endif
</div>
