You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
498 B
23 lines
498 B
<?php
|
|
|
|
namespace App\Domains\Identity\Queries\Dashboard;
|
|
|
|
use App\Domains\Identity\Models\Role;
|
|
|
|
class GetRoleDistributions
|
|
{
|
|
public function fetch(): array
|
|
{
|
|
$roles = Role::select('name')
|
|
->withCount('users')
|
|
->get();
|
|
|
|
$series = $roles->map(fn ($role) => $role->users_count);
|
|
$categories = $roles->map(fn ($role) => $role->name);
|
|
|
|
return [
|
|
'series' => $series,
|
|
'categories' => $categories,
|
|
];
|
|
}
|
|
}
|
|
|