Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $resultTest = \Comanda\Models\Order::query();
- $resultTest->where('orders.id', $order->id);
- ///dd($resultTest->get());
- ////$resultTest->where('produtos.print', '1');
- $resultTest->join('order_produto', 'order_produto.order_id', '=', 'orders.id');
- $resultTest->join('produtos', 'produtos.id', '=', 'order_produto.produto_id');
- $resultTest->groupBy(DB::raw(' IF(produtos.categoria_id IN (1, 2) <> 0, produtos.id, order_produto.id) '));
- $resultTest->orderBy('produtos.id');
- $resultTest->leftJoin('order_tamanho', 'order_tamanho.order_id', '=', 'orders.id');
- $resultTest->leftJoin('tamanhos', 'tamanhos.id', '=', 'order_tamanho.tamanho_id');
- $resultTest->leftJoin('ingrediente_order', 'ingrediente_order.order_id', '=', 'orders.id');
- $resultTest->leftJoin('ingredientes', 'ingredientes.id', '=', 'ingrediente_order.ingrediente_id');
- $resultTest->leftJoin('ingrediextra_order', 'ingrediextra_order.order_id', '=', 'orders.id');
- $resultTest->leftJoin('ingrediextras', 'ingrediextras.id', '=', 'ingrediextra_order.ingrediextra_id');
- $resultTest->select([
- 'orders.id',
- 'produtos.name',
- DB::raw(' tamanhos.name AS tamanho_pizza '),
- /* DB::raw(' GROUP_CONCAT(ingrediextra_order.name) AS ingredientesextra '),
- DB::raw(' GROUP_CONCAT(ingrediente_order.name) AS ingredientes '),*/
- DB::raw('GROUP_CONCAT(DISTINCT ingrediextra_order.name) as ingredientesextra,
- GROUP_CONCAT(DISTINCT ingrediente_order.name) AS ingredientes '
- ),
- DB::raw('sum(ingrediextra_order.price) as totalextra'),
- DB::raw('SUM(order_produto.qtd) as quantidade_pedida '),
- ]);
- $result = $resultTest->get();
- return $result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement