laravel count the types of users

Solutions on MaxInterview for laravel count the types of users by the best coders in the world

showing results for - "laravel count the types of users"
Denzel
18 Aug 2017
1  // laravel count the types of users
2	$roles = Role::pluck('name');
3
4    foreach ($roles as $roleName) {
5        $userCount = User::whereHas('roles', function($query) use($roleName) {
6            $query->where('name', $roleName);
7        })->count();
8    }
similar questions
queries leading to this page
laravel count the types of users