Sometimes you need to extract agrageted data from model. But how to do it with simple and elegant way?! The best practice is to use in Laravel Eloquent ORM than mixing your code with raw SQL.
For example... I need to find cars which are in my table more then ones. It can indicates that car identified by licence plate runs for more than one carriers.
$v = Car::orderBy('licence_plate', 'desc')
->select('licence_plate', DB::raw('count(*) as total'))
->groupBy('licence_plate')
->get();
And now... find cars used more than one time. You can use another clauses where() on after get() and filter records on collection. How it is simple...
$v = Car::orderBy('licence_plate', 'desc')
->select('licence_plate', DB::raw('count(*) as total'))
->groupBy('licence_plate')
->get()
->where('total', '>', 1);
Do something amazing in Laravel!