@extends('layout.layout')

@section('content')
<div class="card shadow-none border">
  <div class="card-body p-24">
    <div class="d-flex justify-content-between align-items-center mb-3">
      <h5 class="mb-0">Permissions</h5>
      <a href="{{ route('admin.permissions.create') }}" class="btn btn-primary btn-sm">Tambah Permission</a>
    </div>

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

    <div class="table-responsive">
      <table class="table table-sm">
        <thead>
          <tr>
            <th>Nama</th>
            <th>Aksi</th>
          </tr>
        </thead>
        <tbody>
          @foreach($permissions as $permission)
          <tr>
            <td>{{ $permission->name }}</td>
            <td>
              <a href="{{ route('admin.permissions.edit', $permission) }}" class="btn btn-sm btn-outline-secondary">Edit</a>
              <form action="{{ route('admin.permissions.destroy', $permission) }}" method="POST" class="d-inline" onsubmit="return confirm('Hapus permission ini?')">
                @csrf
                @method('DELETE')
                <button class="btn btn-sm btn-outline-danger">Hapus</button>
              </form>
            </td>
          </tr>
          @endforeach
        </tbody>
      </table>
    </div>

    {{ $permissions->links() }}
  </div>
</div>
@endsection

