@extends('layouts.app')

@section('content')
<div class="container">
    <h2>Commissions</h2>
    <a href="{{ route('commission.reports') }}" class="btn btn-primary mb-3">Commission Reports</a>

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

    <table class="table table-bordered">
        <thead>
            <tr>
                <th>ID</th>
                <th>Car Sale</th>
                <th>Date</th>
                <th>Buyer Commission</th>
                <th>Seller Commission</th>
                <th>Receiver</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            @foreach($commissions as $commission)
                <tr>
                    <td>{{ $commission->id }}</td>
                    <td>{{ $commission->carSale->registration_no }} | {{ $commission->carSale->make }} | {{ $commission->carSale->varient }} | {{ $commission->carSale->model }} <br> ({{ $commission->buyer_name }} → {{ $commission->seller_name }})</td>
                    <td>{{ $commission->date }}</td>
                    <td>{{ $commission->buyer_commission }}</td>
                    <td>{{ $commission->seller_commission }}</td>
                    <td>{{ $commission->receiver_name }}</td>
                    <td>
    <a href="{{ route('commissions.show', $commission->id) }}" class="btn btn-info btn-sm" title="View">
        <i class="fas fa-eye"></i>
    </a>
    <a href="{{ route('commissions.edit', $commission->id) }}" class="btn btn-success btn-sm" title="Edit">
        <i class="fas fa-edit"></i>
    </a>
    <form action="{{ route('commissions.destroy', $commission->id) }}" method="POST" style="display:inline;">
        @csrf @method('DELETE')
        <button class="btn btn-danger btn-sm" onclick="return confirm('Delete this commission?')" title="Delete">
            <i class="fas fa-trash"></i>
        </button>
    </form>
</td>

                </tr>
            @endforeach
        </tbody>
    </table>

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




<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
