@extends('layout.master')

@push('plugin-styles')
@endpush

@section('content')
<div class="row">
  

  <div class="col-lg-12 grid-margin stretch-card">
    <div class="card">
      
      <div class="card-body">
      @if (session('status'))
          <div class="row clearfix">
              <div class="col-sm-12">
                  <div class="alert alert-success">
                      {{ session('status') }}
                  </div>
              </div>
          </div>
      @endif

        @can('author-create')
        <div>
          <a href="{{ route('autor.create') }}" class="btn btn-primary btn-fw btn-add"><i class="mdi mdi-plus"></i>Adicionar</a>
        </div>
        @endcan
        <h4 class="card-title">Autores </h4>
        <p class="card-description"> Listagem de autores </p>
        <div class="table-responsive">
          <table class="table table-striped">
            <thead>
              <tr>
                <th> Id </th>
                <th> Nome </th>
                <th> Ações </th>
              </tr>
            </thead>
            <tbody>
            @forelse($authors as $author)
              <tr>
                <td> {{ $author->id }} </td>
                <td> {{ $author->name }} </td>
                <td> 
                    <form action="{{route('autor.destroy', $author->id)}}" method="post">
                        @can('author-edit')
                        <a title="Editar" class="btn btn-icons btn-inverse-warning" href="{{route('autor.edit', $author->id)}}"><i class="mdi mdi-grease-pencil"></i></a>
                        @endcan
                        @can('author-delete')
                        {{method_field('DELETE')}}
                        {{csrf_field()}}
                        <button title="Deletar" class="btn btn-icons btn-inverse-danger btn-delete"><i class="mdi mdi-delete"></i></button>   
                        @endcan
                    </form>     
                </td>
              </tr>
              @empty
            </tbody>
              <tr>
                <td colspan="6">Nenhum registro encontrado.</td>
              </tr>
            @endforelse
          </table>
          {{ $authors->links() }}
        </div>
      </div>
    </div>
  </div>
  
</div>
@endsection

@push('plugin-scripts')
@endpush

@push('custom-scripts')
@endpush

        