@extends('admin.layouts.layout')
@section('content')
<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 Arquivo</h4>
                <p class="text-muted">Editando Arquivo ou Documento do Sistema</p>
                <a class="btn btn-outline-primary w-100" type="button" href="{{ route('arquivos.index') }}" role="button">Ver
                    todos</a>
            </div>

            <div class="card">
                <div class="card-body">
                    <form action="{{ route('arquivos.update', $arquivo->id) }}" method="POST" class="form-horizontal"
                        enctype="multipart/form-data">
                        @method('PUT')
                        @csrf
                        <div class="box box-info">

                            <div class="form-group">
                                <label class="col-form-label">Título do arquivo</label>
                                <input type="text" name="titulo" value="{{ $arquivo->titulo }}"
                                    class="form-control @error('titulo') is-invalid @enderror">
                            </div>

                            <div class="form-group">
                                <label class="control-label">Tipo <span>*</span></label>
                                <select class="form-control select2" name="tipo">
                                    @foreach ($arquivostipo as $tipo)
                                        <option value="{{ $tipo->tipo_nome }}"
                                            @if ($arquivo->tipo == $tipo->tipo_nome) selected @endif>{{ $tipo->tipo_nome }}
                                        </option>
                                    @endforeach
                                </select>
                            </div>

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

                                <div class="form-group col-md-6">
                                    <label class="col-form-label">Data da publicação</label>
                                    <input type="date" name="publicacao" value="{{ $arquivo->publicacao }}"
                                        class="form-control @error('publicacao') is-invalid @enderror">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-form-label">Arquivo já publicado</label>
                                <br>
                                <object data="{{ url('assets/site/uploads/dom/' . $arquivo->nome) }}"
                                    height="100"></object>
                                <br>
                                <div class="form-row">
                                    <div class="form-group col-md-10">
                                        <label class="col-form-label">Novo arquivo</label>
                                        <input type="file" name="nome"
                                            class="form-control @error('nome') is-invalid @enderror">
                                    </div>
                                    <div class="form-group col-md-2">
                                        <label class="control-label">Covid?</label>
                                        <select class="form-control" name="covid" value="{{ $arquivo['covid'] }}">
                                            <option value="N" @if ($arquivo['covid'] == 'N') selected @endif>Não
                                            </option>
                                            <option value="S" @if ($arquivo['covid'] == 'S') selected @endif>Sim
                                            </option>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-2">
                                        <label class="control-label">Concurso?</label>
                                        <select class="form-control" name="concurso" value="{{ $arquivo['concurso'] }}">
                                            <option value="N" @if ($arquivo['concurso'] == 'N') selected @endif>Não
                                            </option>
                                            <option value="S" @if ($arquivo['concurso'] == 'S') selected @endif>Sim
                                            </option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <input type="submit" value="Gravar" class="btn btn-sm btn-outline-success w-100">
                        </div>
                </div>

            </div>
        </div>
    </div>
</div>
@endsection
