dealhub/routes/api/deals.php
kusowl 0789c21100 feature(deal approval): admin can approve the deals
- admin can see the deal details in modal
- admin can approve or delete the deals
2026-01-28 18:21:48 +05:30

19 lines
470 B
PHP

<?php
use App\Http\Resources\DealResource;
use App\Models\Deal;
use App\Queries\ExplorePageDealsQuery;
Route::get('/deals/{deal}', function (Deal $deal) {
$query = (new ExplorePageDealsQuery)->builder();
if (! Auth::user()->isAdmin()) {
$query // Select only admin-approved deals
->tap(fn ($q) => (new Deal)->withActiveDeals($q));
}
$query->where('id', $deal->id);
return new DealResource(
$query->first()
);
});