Search
 
SCRIPT & CODE EXAMPLE
 

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();
    }
Comment

PREVIOUS NEXT
Code Example
Php :: yii2 rollback last migration 
Php :: php run cron evey hour 
Php :: sample test tinker php artisan 
Php :: utf8mb4 decode in php 
Php :: laravel create multiple request 
Php :: where post_type like 
Php :: Laravel group collection and sort by the biggest value 
Php :: how to pass value in app.blade 
Php :: php count words in string 
Php :: https://stackoverflow.com/questions/34545641/php-artisan-makeauth-command-is-not-defined 
Php :: remove rank math next prev canonical 
Php :: mysqli_query() expects parameter 1 to be mysqli 
Php :: What does this mean in PHP: - or = 
Php :: featured image tab not displayed on post 
Php :: array with key value pair php 
Php :: static functions php 
Php :: iterate collection laravel 
Php :: Round A Number 
Php :: display rounded price get_price php 
Php :: Convert Shamsi Jalali Persian Date TimeStamp 
Php :: Best Image Manipulation and Graphs tools for php 
Php :: laravel livewire public property 
Php :: php default argument 
Php :: 0.01 bnb to php 
Php :: file_get_contents vs readfile speed 
Php :: namespace not working php 
Php :: virtual fields cakephp 4 
Php :: add user role to wp admin page css 
Php :: dispaly image on front end of custom taxonomy 
Php :: sync fetch eloquent laravel 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =