2
I have two tables, a call proposals and another propostas_items
propostas
-id
-nome
-descricao
propostas_itens
-id
-proposta_id
-quantidade
-valor
A proposal has many items, I need to list the proposals according to their total value, so I have to sum the value of all the items related to a proposal and make an orderby for this value, but I’m not able to do this in Laravel I use version 5.7
I tried to do a Join() and then a groupBy() but I can’t group the results and then operate them in orderby()
$propostas->join('propostas_itens', 'propostas_itens.proposta_id', '=', 'propostas.id')->groupBy('propostas_itens.proposta_id');
I’m grateful for all your help!