@extends('admin.layouts.app')

@section('title', 'Pesquisa de Municipios')

@section('content')
    <h1>Exibindo os municipios</h1>
    {{-- <a href="{{ route('municipios.create') }}" class="btn btn-primary">Cadastrar</a> --}}
    <hr> 
    <form action="{{ route('municipios.search') }}" class="form form-inline" method="POST">
        @csrf
    <input type="text" name="filter" placeholder="Filtrar:" class="form-control" value="{{ $filters['filter'] ?? '' }}">
        <button type="submit" class="btn btn-info">Pesquisar</button>
    </form>

    <table class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>NOME</th>
                <th width="100">AÇÕES</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($municipios as $municipio)
            <tr>
            <td>{{ $municipio->id }}</td>
            <td>{{ $municipio->nome }}</td>

            <td>
            {{-- <a href="{{ route('municipios.edit', $municipio->id) }}">Editar</a> --}}
            <a href="{{ route('municipios.show', $municipio->id) }}">Detalhes</a>
            </td>
            </tr>
                
            @endforeach
        </tbody>
    </table>

    @if (isset($filters))
        {!! $municipios->appends($filters)->links() !!}    
    @endif
        {!! $municipios->links() !!}

@endsection


   