Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel model db raw count

$rating = User::query()
        ->join('championship_sessions', 'users.id', '=', 'championship_sessions.user_id')
        ->whereBetween('championship_sessions.created_at', [
           $activeChampionship['data']['start_time'],
           $activeChampionship['data']['end_time'],
        ])
        ->where('championship_sessions.status', '=', 1)
        ->groupBy('users.id')
        ->orderBy('users.rating', 'desc')
        ->select(['users.id', 'users.name', DB::raw('COUNT(championship_sessions.status) as rating'), 'users.status_name', 'users.status_id'])
        ->paginate(100)->toArray();
Comment

laravel db raw count where

 $users= User::query()
                ->where('users.ban', '!=', 1)
                ->where('users.rights', '=', 1)
                ->leftJoin('users as referal', 'users.id', '=', 'referal.ref_id')
                ->whereNotNull('referal.id')
                ->select([
                    'users.id',
                    'users.name',
                    'users.telegram_id',
                    DB::raw('count(referal.id) as total_referal'),
                ])
                ->groupBy('users.id')
    ->orderByDesc('total_referal')->paginate(100);
Comment

PREVIOUS NEXT
Code Example
Php :: php check if weekends 
Php :: how to display all posts assocatied to user in laravel 
Php :: laravel project preparation,laravel project create 
Php :: how do i implement blockchain payments on laravel website 
Php :: laravel migrate patth 
Php :: HTTP Authentication example forcing a new name/password 
Php :: Submit and draft button use in laravel 
Php :: laravel carbon subtract minutes to current time 
Php :: bar chart in js,php prt 1 
Php :: date fomat in php 
Php :: if laravel pagiantion not found error occured then 
Php :: compare strings alphabetically php 
Php :: string replace in php 
Php :: shopware redirect ot homepage 
Php :: apagar windows desde consola 
Php :: array value auto fill in old value laravel 8 
Php :: symmetric decryption in php 
Php :: laravel 8 storing dynamic checkbox integer value array 
Php :: php array merge 
Php :: print select sql result in php 
Php :: data validation of $_POST in php 
Php :: fichier wp-config.php 
Php :: Codeingiter Pagination 
Php :: atom emmet php 
Php :: laravel easy form 
Php :: php array_intersect_assoc 
Php :: laravel Relations transform 
Php :: disable laravel cors 
Php :: php convert html code to text 
Php :: instagram api error 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =