@extends('layout.master')

@push('plugin-styles')
@endpush

@section('content')
<div class="row">
    <div class="col s12">
        @include('componentes._breadcrumbs')
    </div>

    <div class="col-lg-12 grid-margin stretch-card">
        <div class="card">

            <div class="card-body">

                <h4 class="card-title">Editar case home</h4>
                <p class="card-description"> </p>

                @if ($errors->any())
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div><br />
                @endif

                <div class="auto-form-wrapper">
                    <form action="{{ route('caseHome.update', $obj->id)}}" method="post" enctype="multipart/form-data">
                        {{ csrf_field() }}
                        {{ method_field('PUT') }}

                        <input type="hidden" name="old_image" value="{{ isset($obj->image) ? $obj->image : '' }}">

                        <div class="row clearfix">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-group">
                                        <select name="case_id" class="form-control" require>
                                            <option value="">Selecione um case</option>
                                            @if ($cases)
                                                @foreach($cases as $sol)
                                                    <option value="{{ $sol->id}}" {{ ($sol->id == @$obj->blogPost->id) ? 'selected' : '' }}>{{ $sol->title }}</option>
                                                @endforeach
                                            @endif
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row clearfix">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-field">
                                        <select name="language_id" id="language_id" class="form-control" required>
                                            <option value="">Selecione um Idioma</option>
                                            <option value="pt" {{ ($obj->language_id == 'pt') ? 'selected' : '' }}>Português</option>
                                            <option value="es" {{ ($obj->language_id == 'es') ? 'selected' : '' }}>Espanhol</option>
                                            <option value="en" {{ ($obj->language_id == 'en') ? 'selected' : '' }}>Inglês</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row clearfix">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="file" name="image" id="image" class="form-control">
                                    </div>
                                    <p>Largura máxima da imagem: 1206px</p>
                                </div>
                            </div>
                        </div>
                        @if( $obj->image != '' )
                        <div class="row clearfix">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-group content-img-image">
                                    <img src="{{ isset($obj->image) ?   url('storage/caseHome/'.$obj->image) : '' }}"  width="200px"  />
                                    <a title="Remover Imagem" class="btn btn-icons btn-inverse-danger bt-excluir-img" data-token="{{ csrf_token() }}" data-id="{{ $obj->id }}" data-pagina="case_homes" data-campo="image"><i class="mdi mdi-delete"></i></a>    
                                    </div>
                                </div>
                            </div>
                        </div>
                        @endif


                        
                        <div class="row clearfix">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="titulo" id="titulo" class="validate form-control"
                                            value="{{ isset($obj->titulo) ?  $obj->titulo : old('titulo')}}"
                                            Placeholder="Título" >
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="row clearfix">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <p>Descrição</p>
                                    <div class="input-group">
                                        <textarea name="description" id="description" class="description">{{ isset($obj->description) ?  $obj->description : old('description')}}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="row clearfix">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="btncta" id="btncta" class="validate form-control"
                                            value="{{ isset($obj->btncta) ?  $obj->btncta : old('btncta')}}"
                                            Placeholder="Botão Cta" >
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="btnlinkcta" id="btnlinkcta" class="validate form-control"
                                            value="{{ isset($obj->btnlinkcta) ?  $obj->btnlinkcta : old('btnlinkcta')}}"
                                            Placeholder="Link Botão Cta" >
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row clearfix">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="bt_color" id="bt_color" class="validate form-control"
                                            value="{{ isset($obj->bt_color) ?  $obj->bt_color : old('bt_color')}}"
                                            Placeholder="Cor do botão" >
                                    </div>
                                </div>
                            </div>
                            
                        </div>

                            
                        <div class="row clearfix">
                            <div class="col-sm-2">
                                <button class="btn btn-primary submit-btn btn-block">Atualizar</button>
                            </div>
                        </div>

                    </form>
                </div>

            </div>
        </div>

    </div>
</div>
@endsection

@push('plugin-scripts')
@endpush

@push('custom-scripts')
@endpush