@extends('layouts.layout')


@section('content')
    @if ($message = Session::get('success'))
        <div class="alert alert-success">
            <p>{{ $message }}</p>
        </div>
    @endif


    <div class="panel panel-default">
        <div class="panel-heading">
            <h2>Priorities Management
                <a href="{{ route('priorities.create') }}" class="btn btn-primary pull-right">Create new priority</a>
            </h2>
        </div>

        <div id="message"></div>
        <table class="table table-hover">
            <thead>
            <tr>
                <td>ID</td>
                <td>Name</td>
                <td>Action</td>
            </tr>
            </thead>
            <tbody>
            @foreach ($priorities as $priority)
                <tr>
                    <td>{{ ++$i }}</td>
                    <td>{{ $priority->name }}</td>
                    <td>
                        <form action="{{ route('priorities.destroy',$priority->id) }}" method="POST">

                            <a class="btn btn-primary" href="{{ route('priorities.edit',$priority->id) }}">Edit</a>


                            @csrf
                            @method('DELETE')


                            <button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete the priority: {{ $priority->name }} ?')">Delete</button>
                        </form>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        <div class="pull-left">
            {!! $priorities->links() !!}
        </div>

    </div>
    </div>



@endsection