@extends('layouts.master')
@section('title', 'Manage Agency')
@section('content')
<!-- [ Main Content ] start -->
<div class="row">
<div class="col-md-12">
<div class="card shadow-sm">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">Agency List</h5>
<a href="{{ route('admin.agency.create') }}" class="btn btn-primary btn-sm">+ Add Agency</a>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover align-middle text-center">
<thead class="table-white">
<tr>
<th>SL</th>
<th>Logo</th>
<th>Name</th>
<th>User Count</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@forelse($agencies as $index => $agency)
<tr>
<td>{{ $index + 1 }}</td>
<td>
@if ($agency->logo)
<img src="{{ asset($agency->logo) }}" alt="Logo"
width="50" height="50">
@else
<span class="text-muted">No Logo</span>
@endif
</td>
<td>{{ $agency->name }}</td>
<td>{{ \App\Models\User::where('company_id', $agency->id)->count() }}</td>
<td>
<!-- Replace with actual route names or actions -->
<a href="{{ route('admin.agency.edit', $agency->id) }}"
class="btn btn-sm btn-primary">Edit</a>
<form action="{{ route('agency.destroy', $agency->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?')">Delete</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="5">No agencies found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- [ Main Content ] end -->
@endsection