@php
  $search = isset($_GET['search']) ? $_GET['search'] : $_GET['search']= '';
@endphp
<div class="card prodcard">
  <div class="card-body">
    <form action="{{route('admin.pesqCategoria')}}" method="get">
      {{ csrf_field() }}
      <div class="input-group mb-sm-3">
        <input type="text" class="form-control" name="search" placeholder="Ex: Categoria" value="{{$search}}">
        <div class="input-group-append">
          <button class="btn btn-outline-secondary" type="submit">Pesquisar</button>
        </div>
        <div class="input-group-append">
          <button class="btn btn-outline-secondary" type="button"
                  onclick="location.href = '{{ route('admin.cadastrarCategoria') }}'">Cadastrar
          </button>
        </div>
      </div>
    </form>
    <table class="table table-sm table-hover ">{{-- table-bordered --}}
      <thead>
      <tr class="row small">
        <th class="col-xs-2 col-sm-2 col-md-2 col-lg-2">Código</th>
        <th class="col-xs-7 col-sm-7 col-md-7 col-lg-5">Descrição</th>
        <th class="text-center col-xs-3 col-sm-3 col-md-3 col-lg-5">Ação</th>
      </tr>
      </thead>
      <tbody>
      @foreach ($categorias as $cat)
        <tr class="row">
          <td class="col-xs-2 col-sm-2 col-md-2 col-lg-2">{{$cat->codigo}}</td>
          <td class="col-xs-5 col-sm-5 col-md-5 col-lg-5">{{$cat->descricao}}</td>
          <td class="text-center col-xs-3 col-sm-3 col-md-3 col-lg-5">
            {{--		    	<button class="btn btn-sm btn-outline-success col-lg-4 col-md-6 col-sm-12" type="button" data-toggle="modal" data-target="#modalEditar{{$prod->codigo}}">Editar</button>--}}
            <button class="btn btn-sm btn-outline-success col-lg-4 col-md-6 col-sm-12" type="submit"
                    onclick="location.href = '{{ route('admin.manCategoria',$cat->codigo) }}'">Editar
            </button>
            <button class="btn btn-sm btn-outline-danger col-lg-4 col-md-6 col-sm-12" type="button" data-toggle="modal"
                    data-target="#modalDel{{$cat->codigo}}">Deletar
            </button>
          </td>
        </tr>
        {{-- modaldel --}}
        <div class="modal fade" id="modalDel{{$cat->codigo}}" tabindex="-1" role="dialog"
             aria-labelledby="modalDel.{{$cat->codigo}}" aria-hidden="true">
          <div class="modal-dialog modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header text-right">
                <h5 class="text-center">Deseja realmente excluir esta Categoria?</h5>
              </div>
              <div class=" modal-footer align-content-center">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</button>
                <button type="button" class="btn btn-danger "
                        onclick="location.href = '{{ route('admin.deleteCategoria',$cat->codigo  ) }}'">Excluir
                </button>
              </div>
            </div>
          </div>
        </div>
      @endforeach
      </tbody>
    </table>
    <div class="row justify-content-sm-center pagprod">
      {{ $categorias->links() }}
    </div>
  </div>
</div>

