@extends('admin.layouts.layout')
@section('title', 'Editando notícia')
@section('content')
    <script src="https://cdn.tiny.cloud/1/rcjw03tjfu0hq8dkm2bkb8qcwhd4nyavx70mdvyk6t6a8uzl/tinymce/6/tinymce.min.js"
        referrerpolicy="origin"></script>
    <div class="row match-height">
        <div class="col-md-12 col-12">
            <div class="card">
                <div class="card-header">
                    <h4 class="card-title text-primary">Editando Notícia</h4>
                    <p class="text-muted">Editando Notícia no Sistema</p>
                    <a class="btn btn-outline-primary btn-block d-grid gap-2" type="button"
                        href="{{ route('noticias.index') }}" role="button">Ver todas</a>
                </div>
                <div class="card">
                    <div class="card-body">
                        <form action="{{ route('noticias.update', $noticias->id) }}" method="POST" class="form-horizontal"
                            enctype="multipart/form-data">
                            @method('PUT')
                            @csrf
                            <div class="box box-info">
                                <input type="text" name="total_visualizacoes" value="0" hidden>
                                <div class="form-group">
                                    <label class="col-form-label">Título da notícia <span>*</span></label>
                                    <input type="text" name="noticias_titulo" value="{{ $noticias->noticias_titulo }}"
                                        class="form-control @error('noticias_titulo') is-invalid @enderror">
                                </div>

                                <div class="form-group">
                                    <label class="col-form-label">Slug <span>*</span></label>
                                    <input type="text" name="noticias_slug" value="{{ $noticias->noticias_slug }}"
                                        class="form-control @error('noticias_slug') is-invalid @enderror" disabled>
                                </div>

                                <div class="form-group" id="showPageContent">
                                    <label class="col-form-label">Conteúdo </label>
                                    <textarea type="textarea" class="form-control @error('noticias_conteudo') is-invalid @enderror" rows="5"
                                        name="noticias_conteudo">{{ $noticias->noticias_conteudo }}</textarea>
                                </div>

                                <div class="row">
                                    <div class="form-group col-md-6">
                                        <label>Data <span>*</span></label>
                                        <input type="date" name="noticias_data" value="{{ $noticias->noticias_data }}"
                                            class="form-control @error('noticias_data') is-invalid @enderror">
                                    </div>

                                    <div class="form-group col-md-6">
                                        <label>Categorias <span>*</span></label>
                                        <select class="form-control @error('id_categoria') is-invalid @enderror"
                                            name="id_categoria" value="{{ old('id_categoria') }}">
                                            <option value="">Selecione uma categoria</option>
                                            @foreach ($secretarias as $secretaria)
                                                <option value="{{ $secretaria->id }}">{{ $secretaria->nome }}
                                                </option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">

                                    <label class="col-form-label">Foto principal</label>
                                    <br>
                                    <object data="{{ url('assets/site/uploads/noticias/' . $noticias->foto) }}"
                                        height="100"></object>
                                    <br>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label class="col-form-label">Nova foto</label>
                                            <input type="file" class="form-control @error('foto') is-invalid @enderror"
                                                name="foto" value="{{ $noticias->foto }}">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group col-md-4">
                                        <label class="col-form-label">Publicador <span>*</span></label>
                                        <input type="text" name="publicador" value="{{ $noticias->publicador }}"
                                            class="form-control @error('publicador') is-invalid @enderror" disabled>
                                    </div>
                                    <div class="form-group col-md-2">
                                        <label class="col-form-label">Covid</label>
                                        <select class="form-control" name="covid" value="{{ $noticias['covid'] }}">
                                            <option value="S" @if ($noticias['covid'] == 'S') selected @endif>Sim
                                            </option>
                                            <option value="N" @if ($noticias['covid'] == 'N') selected @endif>Não
                                            </option>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-2">
                                        <label class="col-form-label">Concurso</label>
                                        <select name="concurso" class="form-control @error('concurso') is-invalid @enderror"
                                            value="{{ $noticias['concurso'] }}">
                                            <option value="N" @if ($noticias['concurso'] == 'N') selected @endif>Não
                                            </option>
                                            <option value="S" @if ($noticias['concurso'] == 'S') selected @endif>Sim
                                            </option>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-2">
                                        <label class="col-form-label">Período Eleitoral</label>
                                        <select name="periodo_eleitoral"
                                            class="form-control @error('periodo_eleitoral') is-invalid @enderror"
                                            value="{{ $noticias['periodo_eleitoral'] }}">
                                            <option value="N" @if ($noticias['periodo_eleitoral'] == 'N') selected @endif>Não
                                            </option>
                                            <option value="S" @if ($noticias['periodo_eleitoral'] == 'S') selected @endif>Sim
                                            </option>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-2">
                                        <label class="col-form-label">CACS</label>
                                        <select name="cacs" class="form-control @error('cacs') is-invalid @enderror"
                                            value="{{ $noticias['cacs'] }}">
                                            <option value="N" @if ($noticias['cacs'] == 'N') selected @endif>Não
                                            </option>
                                            <option value="S" @if ($noticias['cacs'] == 'S') selected @endif>Sim
                                            </option>
                                        </select>
                                    </div>
                                </div>

                                <h3 class="seo-info">SEO Informações</h3>
                                <div class="form-group">
                                    <label class="col-form-label">Meta Título </label>
                                    <input type="text" class="form-control @error('meta_titulo') is-invalid @enderror"
                                        name="meta_titulo" value="{{ $noticias->meta_titulo }}"
                                        placeholder="Esse campo será preenchido automaticamente pelo sistema" disabled>
                                </div>

                                <div class="form-group">
                                    <label class="col-form-label">Meta Keywords </label>
                                    <input type="text" type="text"
                                        class="form-control @error('meta_keyword') is-invalid @enderror"
                                        name="meta_keyword" rows="2" value="{{ $noticias->meta_keyword }}">
                                </div>

                                <div class="form-group">
                                    <label class="col-form-label">Meta Descrição </label>
                                    <input type="text"
                                        class="form-control @error('meta_descricao') is-invalid @enderror"
                                        name="meta_descricao" rows="2" value="{{ $noticias->meta_descricao }}">
                                </div>

                                <div class="form-group">
                                    <button type="submit" class="btn btn-outline-success btn-sm btn-block"
                                        name="form1">Gravar</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <script>
        tinymce.init({
            selector: 'textarea',
            plugins: 'advlist autolink lists link image charmap preview anchor pagebreak',
            toolbar_mode: 'floating',
        });
    </script>
    </div>


@endsection
