@extends('admin.masterAdmin')
@section('content')
    <div class="card">
        <div class="card-header d-flex justify-content-between">
            <h5>Manage Services</h5>
            <a href="{{ route('service.create') }}" class="btn btn-primary btn-sm">+ Add Service</a>
        </div>
        <div class="card-body">
            @include('components.alert')
            <div class="table-responsive">
                <table class="table table-bordered w-100" id="dt-responsive">
                    <thead class="thead-light">
                        <tr>
                            <th>S/L</th>
                            <th>Category</th>
                            <th>Image</th>
                            <th>Title</th>
                            <th>Subtitle</th>
                            <th>Description</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($services as $service)
                            <tr>
                                <td>{{ $loop->iteration }}</td>
                                <td>{{ $service->serviceCategory->name ?? 'N/A' }}</td>
                                <td>
                                    @if ($service->image)
                                        <img src="{{ asset($service->image) }}" alt="" width="60">
                                    @endif
                                </td>
                                <td>{{ $service->title }}</td>
                                <td>{{ $service->subtitle }}</td>
                                <td>{{ Str::limit($service->description, 50) }}</td>
                                <td>
                                    <a href="{{ route('service.edit', $service->id) }}" class="btn btn-sm btn-info">Edit</a>
                                    <form action="{{ route('service.destroy', $service->id) }}" method="POST"
                                        style="display:inline-block" onsubmit="return confirm('Delete this service?')">
                                        @csrf
                                        @method('DELETE')
                                        <button class="btn btn-sm btn-danger" type="submit">Delete</button>
                                    </form>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
