Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
893 B
5
Indexable
elseif ($action == 'getStockItem') {
            $query->leftJoin('warehouses', 'warehouses.id', '=', 'report_stocks.warehouse_id');
            $query->leftJoin('locations', 'locations.id', '=', 'report_stocks.location_id');
            $query->leftJoin('items', 'items.id', '=', 'report_stocks.item_id');
            $query->select(
                'items.id as item_id',
                'items.name as item_name',
                'locations.id as location_id',
                'locations.name as location_name',
                DB::raw('SUM(report_stocks.quantity) as quantity')
            );
            $query->where('report_stocks.is_active', 1);
            $query->groupBy(
                'items.id',
                'items.name',
                'locations.id',
                'locations.name',
                'report_stocks.created_at'
            );
        }
Leave a Comment