I had got the result from the query.
My Simple SQL is:
SELECT
o2.driver_id,
total_delieveries,
DATE_FORMAT(o1.created_at ,\'%Y-%m-%d\')
Also show this answer and for your variant:
$subQuery = \DB::table('orders')->selectRaw('driver_id, created_at, COUNT(driver_id) AS total_delieveries')
->where('is_paid', 0)
->where('order_status', '5')
->whereBetween('created_at', [$first_Day, $last_Day])
->groupBy(\DB::raw('DATE_FORMAT(created_at ,"%Y-%m-%d"),driver_id'));
$q = \DB::table(\DB::raw('('.$subQuery->toSql().') as o1'))
->selectRaw('o2.driver_id,total_delieveries,DATE_FORMAT(o1.created_at ,"%Y-%m-%d") AS created_at')
->join('orders as o2', 'o1.driver_id', '=', 'o2.driver_id')
->groupBy('o1.created_at')
->mergeBindings($subQuery)
->get();