javascript - Count value db Laravel
Solution:
What you are looking for is called a group by
, I have added a sample query below, Because without proper table description and exact output requirement its hard to provide a correct answer, But the following should give you a direction.
$itemsCount = DB::table('items')
->groupby('level_id')
->selectRaw('level_id, count(*) as apartment_count');
you should be able to get an output similar to the following
+