@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">

                @if (session('status'))
                    <div class="row clearfix">
                        <div class="col-sm-12">
                            <div class="alert alert-success">
                                {{ session('status') }}
                            </div>
                        </div>
                    </div>
                @endif

                <h4 class="card-title">Editar Páginas</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('pagina.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-12">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="name" id="name" class="validate form-control"
                                            Placeholder="Título da página" value="{{ isset($obj->name) ?  $obj->name : old('name')}}" >
                                    </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>
                                </div>
                            </div>
                        </div>

                        @if (isset($obj->image)) 
                        <div class="row clearfix">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <div class="input-group content-img-images_pt">
                                    <img src="{{ isset($obj->image_pt) ?   url('storage/pagina/'.$obj->image_pt) : '' }}" 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="paginas" data-campo="image_pt"><i class="mdi mdi-delete"></i></a>    
                                    </div>
                                </div>
                            </div>
                        </div>
                        @endif
                                

                        <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>

                                
                        <h5 class="title_section">Meta Tags</h5>
                        <div class="row clearfix">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="meta_title" id="meta_title" class="validate form-control"
                                            value="{{ isset($obj->meta_title) ?  $obj->meta_title : old('meta_title')}}"
                                            Placeholder="Meta Title" >
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row clearfix">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="meta_description" id="meta_description" class="validate form-control"
                                            value="{{ isset($obj->meta_description) ?  $obj->meta_description : old('meta_description')}}"
                                            Placeholder="Meta Description" >
                                    </div>
                                </div>
                            </div>
                        </div>                        

                        
                        <div class="row clearfix">
                            <div class="col-sm-4">
                                <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