In my app I want to find greater value count and the row which its count by groupBy and also find which element has count and make it higher, for example, there are value 1 is 2 row and value 2 is 3 row and value 3 is 2 rows so I need the higher counts and it value in this cause it will find value 2 and count is 3 because it is three times . so how to get value 2 and its count is 3 both value and its count.such as value 2 and count 3.
$status_order = DB::table('shipments')
->select('shipment_status_id', DB::raw('count(shipment_status_id) as count_status_id'))
->groupBy('shipment_status_id')
->where('order_id', $order->id)
->get();
Whatever I have understood from your problem I think you are looking for this.
$status_order = DB::table('shipments')
->selectRaw('`shipment_status_id` as `value`, count(`shipment_status_id`) as `count`')
->groupBy('value')
->orderBy('count', 'desc')
->first();