@extends('layouts.app')

@section('content')
    <div class="container">
        <div>
            <h2 class="pb-2">Bibliothèque projets
                @if(Auth::user()->can('add_bibliotheque_projets'))
                    <a class="btn btn-outline-success float-right mb-4" href="{{ route('bibliotheque_projets.create') }}">Ajouter</a>
                @endif
            </h2>
        </div>

        @include('layouts.commons.errors')
        @include('layouts.commons.success')

        @if(sizeof($bibliotheque_projets) > 0)
            <table class="table table-striped table-bordered">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>Objet</th>
                    <th>Actions</th>
                </tr>
                </thead>
                <tbody>
                @foreach($bibliotheque_projets as $p)
                    <tr>
                        <td>{{ $p->id }}</td>
                        <td>{{ $p->objet }}</td>
                        <td style="width: 15%">
                            <a class="btn btn-outline-info" href="{{ route('bibliotheque_projets.show', $p->id) }}"
                                data-toggle="tooltip" data-placement="top" title="Voir">
                                <i class="fas fa-eye"></i>
                            </a>
                            @can('creer_projet_from_bibliotheque_projets')
                                <a class="btn btn-outline-primary" href="{{ route('bibliotheques_projets.creer_projet', $p->id) }}"
                                    data-toggle="tooltip" data-placement="top" title="Créer projet">
                                    <i class="fas fa-folder-plus"></i>
                                </a>
                            @endcan
                            @can('delete_bibliotheque_projets')
                                <form class="inline-form-table" action="{{ route('bibliotheque_projets.destroy', $p->id) }}" method="POST">
                                    @csrf
                                    {{ method_field('DELETE') }}
                                    <button type="submit" class="btn btn-outline-danger"
                                        data-toggle="tooltip" data-placement="top" title="Supprimer">
                                        <i class="fas fa-trash-alt"></i>
                                    </button>
                                </form>
                            @endcan
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>

            {{-- {{ $bibliotheque_projets->links("pagination::bootstrap-4") }} --}}
        @else
            <div class="pt-2">
                <h4>Pas de données disponible.</h4>
            </div>
        @endif
    </div>
@endsection
