dealhub/app/Actions/GetUserFavoritesAction.php
kusowl 94ef8f360d feature (favorite and reported deals):
- add favorites and reported tabs in user profile pages
- add remove favorites
- customers can view a deal directly from profiles section and deal modal is shown in explore page
- fix formatting by pint
2026-01-23 16:14:04 +05:30

21 lines
491 B
PHP

<?php
namespace App\Actions;
use App\Enums\InteractionType;
use App\Models\Deal;
use App\Models\User;
use Illuminate\Support\Collection;
final readonly class GetUserFavoritesAction
{
public function execute(User $user): Collection
{
return $user->interactedDeals()
->where('interactions.type', InteractionType::Favorite)
->tap(fn ($q) => (new Deal)->withActiveDeals($q))
->select('deals.id', 'deals.title')
->get();
}
}