<?php
@extends('layouts.app')
@section('content')
<div class="d-flex justify-content-between align-items-center mb-3">
<h2>Categories</h2>
<a href="{{ route('categories.create') }}" class="btn btn-primary">+ Add Category</a>
</div>
@if(session('success'))
<div class="alert alert-success">{{ session('success') }}</div>
@endif
<table class="table table-striped table-hover">
<thead class="table-dark">
<tr>
<th>#</th>
<th>Name</th>
<th width="200px">Action</th>
</tr>
</thead>
<tbody>
@foreach ($categories as $c)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $c->name }}</td>
<td>
<a href="{{ route('categories.edit', $c) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('categories.destroy', $c) }}" method="POST" class="d-inline">
@csrf @method('DELETE')
<button type="submit" onclick="return confirm('Delete this category?')" class="btn btn-danger btn-sm">
Delete
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
@endsection