23 lines
630 B
PHP
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'),
|
|
];
|
|
}
|
|
}
|