@extends('layouts.backend')

@section('title', $slide->exists ? 'Editando '.$slide->title : 'Crear nuevo')

@section('section', 'Slides')

@section('content')
    {!! Form::model($slide, [
        'method' => $slide->exists ? 'put' : 'post',
        'route' => $slide->exists ? ['backend.slides.update', $slide->id] : 'backend.slides.store',
        'class' => 'form-horizontal',
        'files' => true
    ]) !!}
    <div class="card ">
        <div class="card-header card-header-rose card-header-text">
            <div class="card-text">
                <h4 class="card-title">@yield('title')</h4>
            </div>
        </div>
        <div class="card-body ">
            <div class="row">
                <div class="col-md-8">
                    <div class="row">
                        <label class="col-sm-2 col-form-label">Título</label>
                        <div class="col-sm-10">
                            <div class="form-group">
                                {!! Form::text('title', null, ['class' => 'form-control', 'required']) !!}
                                <span class="bmd-help">Sugerencia.</span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <label class="col-sm-2 col-form-label">Texto</label>
                        <div class="col-sm-10">
                            <div class="form-group">
                                {!! Form::textarea('excerpt', null, ['class' => 'form-control', 'rows' => 3]) !!}
                                <span class="bmd-help">Sugerencia.</span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <label class="col-sm-2 col-form-label">Texto superior</label>
                        <div class="col-sm-10">
                            <div class="form-group">
                                {!! Form::text('caption', null, ['class' => 'form-control', 'required']) !!}
                                <span class="bmd-help">Sugerencia.</span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <label class="col-sm-2 col-form-label">Enlace</label>
                        <div class="col-sm-10">
                            <div class="form-group">
                                {!! Form::text('url', null, ['class' => 'form-control', 'required']) !!}
                                <span class="bmd-help">Sugerencia.</span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        <label class="form-label">Imagen principal</label>
                        <div class="fileinput text-center {{ $slide->image ? 'fileinput-exists' : 'fileinput-new' }}" data-provides="fileinput">
                            <div class="fileinput-new thumbnail">
                                <img src="{{ asset('backend-assets/img/image_placeholder.jpg') }}" alt="...">
                            </div>
                            <div class="fileinput-preview {{ !$slide->image ? 'fileinput-exists' : null }} thumbnail">
                                @if($slide->image)
                                    <img src="{{ asset($slide->image) }}" alt="...">
                                @endif
                            </div>
                            <div>
                                <span class="btn btn-rose btn-round btn-file">
                                    <span class="fileinput-new">Seleccionar imagen</span>
                                    <span class="fileinput-exists">Cambiar</span>
                                    {!! Form::file('image') !!}
                                </span>
                                <a href="#" class="btn btn-danger btn-round fileinput-exists" data-dismiss="fileinput"><i class="fa fa-times"></i> Quitar</a>
                            </div>
                        </div>
                        <span class="bmd-help">{{ $option->text }}</span>
                    </div>
                    <div class="form-group">
                        <label class="form-label">Imagen de fondo</label>
                        <div class="fileinput text-center {{ $slide->image_2 ? 'fileinput-exists' : 'fileinput-new' }}" data-provides="fileinput">
                            <div class="fileinput-new thumbnail">
                                <img src="{{ asset('backend-assets/img/image_placeholder.jpg') }}" alt="...">
                            </div>
                            <div class="fileinput-preview {{ !$slide->image_2 ? 'fileinput-exists' : null }} thumbnail">
                                @if($slide->image_2)
                                    <img src="{{ asset($slide->image_2) }}" alt="...">
                                @endif
                            </div>
                            <div>
                                <span class="btn btn-rose btn-round btn-file">
                                    <span class="fileinput-new">Seleccionar imagen</span>
                                    <span class="fileinput-exists">Cambiar</span>
                                    {!! Form::file('image_2') !!}
                                </span>
                                <a href="#" class="btn btn-danger btn-round fileinput-exists" data-dismiss="fileinput"><i class="fa fa-times"></i> Quitar</a>
                            </div>
                        </div>
                        <span class="bmd-help">{{ $option->text }}</span>
                    </div>
                    <div class="form-group">
                        <label class="form-label">Imagen superior</label>
                        <div class="fileinput text-center {{ $slide->image_3 ? 'fileinput-exists' : 'fileinput-new' }}" data-provides="fileinput">
                            <div class="fileinput-new thumbnail">
                                <img src="{{ asset('backend-assets/img/image_placeholder.jpg') }}" alt="...">
                            </div>
                            <div class="fileinput-preview {{ !$slide->image_3 ? 'fileinput-exists' : null }} thumbnail">
                                @if($slide->image_3)
                                    <img src="{{ asset($slide->image_3) }}" alt="...">
                                @endif
                            </div>
                            <div>
                                <span class="btn btn-rose btn-round btn-file">
                                    <span class="fileinput-new">Seleccionar imagen</span>
                                    <span class="fileinput-exists">Cambiar</span>
                                    {!! Form::file('image_3') !!}
                                </span>
                                <a href="#" class="btn btn-danger btn-round fileinput-exists" data-dismiss="fileinput"><i class="fa fa-times"></i> Quitar</a>
                            </div>
                        </div>
                        <span class="bmd-help">{{ $option->text }}</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="card-footer">
            <button class="btn btn-success">Guardar</button>
        </div>
    </div>
    {!! Form::close() !!}
@endsection

@section('scripts')
<script>
$(function() {
    $('[href="#slides"]').click();
});
</script>
@endsection
