dealhub/app/Queries/ExplorePageDealsQuery.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

35 lines
1008 B
PHP

<?php
namespace App\Queries;
use App\Models\Deal;
use Illuminate\Database\Eloquent\Builder;
final readonly class ExplorePageDealsQuery
{
/**
* @return Builder<Deal>
*/
public function builder(): Builder
{
return Deal::query()
->select([
'id', 'title', 'description', 'image', 'active', 'slug', 'link',
'deal_category_id', 'user_id',
])
// Select additional details
->with([
'category:id,name',
'broker' => function ($query) {
$query->select('id', 'name', 'email', 'role_type', 'role_id')
->with('type');
},
])
// Check if the current user interacted with the deal
->tap(fn ($q) => (new Deal)->withCurrentUserInteractions($q))
->tap(fn ($q) => (new Deal)->withLikePerDeal($q))
->tap(fn ($q) => (new Deal)->withRedirectionPerDeal($q));
}
}