Search
 
SCRIPT & CODE EXAMPLE
 

PHP

group by laravel

$user_info = DB::table('usermetas')
                 ->select('browser', DB::raw('count(*) as total'))
                 ->groupBy('browser')
                 ->get();
Comment

laravel group by with where clause

$groupedSalesCampaign = Order::with('Campaign')
            ->where('isapproved','=','Y')
            ->groupBy('campaign_id')
            ->orderBy(DB::raw('COUNT(id)','desc'))
            ->get(array(DB::raw('COUNT(id) as totalsales'),'campaign_id'));
Comment

laravel grouping where

User::where('username','john doe')
    ->where(function($query)
    {
        $query->where('age','>',30)
        ->orWhere('email','=','johndoe@xyz.com');
    })
    ->toSql();
Comment

laravel groupby and latest

//If You want the latest id of records then you can use unique() after get(),
//don't use group by if you use groupBy 
//then you lose your control from id. I hope this is useful for you

myModel::select('id','purch','name','prcvalue')
  ->where('purch','=','10234')
  ->orderBy('prcvalue','DESC')
  ->get()
  ->unique('name');
Comment

PREVIOUS NEXT
Code Example
Php :: composer require laravel/ui not working laravel 7 
Php :: set subject for mail inlaravel 
Php :: Deleting all files inside a directory laravel 8 
Php :: General error: 1215 Cannot add foreign key constraint laravel 
Php :: save html form data to text file using php 
Php :: laravel check if get is empty 
Php :: replace _ with space php 
Php :: get domain from subdomain php 
Php :: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes 
Php :: symfony get current datetime 
Php :: python truncate file contents 
Php :: collection laravel filter 
Php :: php read xml from url 
Php :: wordpress logout redirect to home 
Php :: ext-dom php 7.2 
Php :: echo alert php 
Php :: west african timezone in php 
Php :: js check if div is empty 
Php :: find distance between two coordinate in php 
Php :: laravel blade date format 
Php :: laravel permission denied storage log 
Php :: where date laravel 
Php :: redirect 301 wordpress 
Php :: get the value of href in anchar tag php 
Php :: header.php file how to fetch in index.php file in wordpress 
Php :: get wordpress id 
Php :: trim elements of array php 
Php :: get http host laravel 
Php :: get country from ip php 
Php :: blade capitalize first letter 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =