@extends('modelo.modelo')

@section('content')

<a href="{{ url('funcionario/show') }}" title="Back"><button class="btn btn-warning  btn-hero btn-sm"><i class="fa fa-arrow-left"
    aria-hidden="true"></i> Voltar</button></a>
    <br>
    <br>
    <div class="block p-4">
        <h3 class="text-center">Editar Funcionario #{{ $funcionario[0]->name }} </h3>
        <div class="row">
            <div class="col-md-6">
                <div class="form-group {{ $errors->has('name') ? 'has-error' : '' }}">
                    <label for="name" class="control-label">{{ 'Nome' }}</label>
                    <input class="form-control" name="name" type="text" id="name" value="{{ $funcionario[0]->name }}">
                    {!! $errors->first('name', '<p class="help-block">:message</p>') !!}
                </div>
                <div class="form-group {{ $errors->has('email') ? 'has-error' : '' }}">
                    <label for="email" class="control-label">{{ 'Email' }}</label>
                    <input class="form-control" name="email" type="email" id="email" value="{{ $funcionario[0]->email }}">
                    {!! $errors->first('email', '<p class="help-block">:message</p>') !!}
                </div>
                <div class="form-group {{ $errors->has('cpf') ? 'has-error' : '' }}">
                    <label for="cpf" class="control-label">{{ 'CPF' }}</label>
                    <input class="form-control" name="cpf" type="text" id="cpf" value="{{ $funcionario[0]->cpf }}">
                    {!! $errors->first('cpf', '<p class="help-block">:message</p>') !!}
                </div>

            </div>
            <div class="col-md-6">

                <div class="form-group {{ $errors->has('cargo') ? 'has-error' : '' }}">
                    <label for="cargo" class="control-label">{{ 'Cargo' }}</label>
                    <input class="form-control" name="cargo" type="text" id="cargo"
                        value="{{ $funcionario[0]->cargo }}">
                    {!! $errors->first('cargo', '<p class="help-block">:message</p>') !!}
                </div>
                <div class="form-group {{ $errors->has('matricula') ? 'has-error' : '' }}">
                    <label for="matricula" class="control-label">{{ 'Matrícula' }}</label>
                    <input class="form-control" name="matricula" type="text" id="matricula"
                        value="{{ $funcionario[0]->matricula }}">
                    {!! $errors->first('matricula', '<p class="help-block">:message</p>') !!}
                </div>
                <label for="matricula" class="control-label">{{ 'Setor' }}</label>
                <select class="form-control" name="idSetor" id="idSetor">
                    <option>Selecione um setor</option>

                    @foreach($setores as $indice => $setor)
                        <option value="{{$indice}}"

                                @if(isset($funcionario[0]) && $funcionario[0]->idSetor == $indice)
                                {{' selected=""'}}
                                @endif

                                >{{$setor}}</option>
                    @endforeach
                </select>
            </div>

            <a class="btn btn-warning  btn-hero" href="{{ url('rotadeinserir') }}">Editar</a>
        </div>

    @endsection
