We can also make our query on groupBy using Laravel 4.x.Let me demonstrate it by the following example.
Suppose we have a table in which we have n number of users which are from different-different state and we have to find that how many users belong to particular state.Then we have to run the following query.
$userInfo = DB::table('user')->select('state', DB::raw('count(*) as total'))->groupBy('state') ->get();
Here In the above example we can count the employee of particular state by using groupBy.
0 Comment(s)