@extends('admin.masterAdmin')

@section('content')
    <div class="card">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">Founders</h5>
            <a href="{{ route('founders.create') }}" class="btn btn-sm btn-primary">Add Founder</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>SL</th>
                            <th>Image</th>
                            <th>Name</th>
                            <th>Designation</th>
                            <th>About</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse ($founders as $founder)
                            <tr>
                                <td>{{ $loop->iteration }}</td>
                                <td>
                                    @if (isset($founder) && $founder->image)
                                        <div class="mt-2">
                                            <img src="{{ asset($founder->image) }}" width="120" alt="founder Image">
                                        </div>
                                    @else
                                        <img src="{{ asset('images/no-image.png') }}" width="80" alt="No Image">
                                    @endif
                                </td>
                                <td>{{ $founder->name }}</td>
                                <td>{{ $founder->position }}</td>
                                <td>{{ $founder->about }}</td>
                                <td>
                                    <a href="{{ route('founders.edit', $founder->id) }}" class="btn btn-sm btn-primary">
                                        Edit
                                    </a>
                                    <form action="{{ route('founders.destroy', $founder->id) }}" method="POST"
                                        class="d-inline-block"
                                        onsubmit="return confirm('Are you sure you want to delete this founder?')">
                                        @csrf
                                        @method('DELETE')
                                        <button class="btn btn-sm btn-danger">Delete</button>
                                    </form>
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="8" class="text-center">No Founder found.</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
