dealhub/app/Actions/GetBrokerStatsAction.php
kusowl 9e7fda4ea2 feature (stats in broker dashboard):
show individual brokers total likes, view and click per deal andin stats
2026-01-22 16:36:22 +05:30

23 lines
630 B
PHP

<?php
namespace App\Actions;
use App\Enums\InteractionType;
use App\Models\User;
final readonly class GetBrokerStatsAction
{
/**
* @return array<string, int>
*/
public function execute(User $user): array
{
return [
'listings' => $user->deals()->count(),
'likes' => $user->dealsInteractions()->where('type', InteractionType::Like)->count(),
'views' => $user->dealsInteractions()->where('type', InteractionType::View)->sum('count'),
'clicks' => $user->dealsInteractions()->where('type', InteractionType::Redirection)->sum('count'),
];
}
}