Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel count the types of users

  // laravel count the types of users
	$roles = Role::pluck('name');

    foreach ($roles as $roleName) {
        $userCount = User::whereHas('roles', function($query) use($roleName) {
            $query->where('name', $roleName);
        })->count();
    }
 
PREVIOUS NEXT
Tagged: #laravel #count #types #users
ADD COMMENT
Topic
Name
7+9 =