@extends('layouts.master')
@section('title', 'List of Roles')
@section('content')
<div class="container">
    <div class="d-flex justify-content-end mb-1">
     <a href="{{ route('roles.create') }}" class="btn btn-primary">Add Role</a>
    </div>
    <div class="card-header bg-primary text-white py-3 mb-4">
       <h5 class="mb-0"><i class="fas fa-users-cog me-2"></i> Roles</h5>
    </div>

    @if(session('success'))
        <div class="alert alert-success">{{ session('success') }}</div>
    @endif

    <table class="table table-bordered">
       <thead style="background-color: #0b7c85;" class="text-white">
            <tr>
                {{-- <th>ID</th> --}}
                <th>Name</th>
                <th>Description</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            @foreach($roles as $role)
                <tr>
                    {{-- <td>{{ $role->id }}</td> --}}
                    <td>{{ $role->name }}</td>
                    <td>
                        {{ $role->description }}
                    </td>
                    <td>
                        <a href="{{ route('roles.edit', $role->id) }}" class="btn btn-sm btn-secondary">Edit</a>
                        <form action="{{ route('roles.destroy', $role->id) }}" method="POST" style="display:inline-block;">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-sm btn-danger"
                                onclick="return confirm('Are you sure you want to delete this role?')">
                                Delete
                            </button>
                        </form>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
</div>
@endsection
