If anybody is interested in future I solved it like this...
$sales = DB::table('order_lines')
->join('orders', 'orders.id', '=', 'order_lines.order_id')
->select(DB::raw('sum(order_lines.quantity*order_lines.per_qty) AS total_sales'))
->where('order_lines.product_id', $product->id)
->where('orders.order_status_id', 4)
->first();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community