0
cannot create the total result of Quantity * value_unitario - discount, and also the sum of these totals, of the table that is related.
Model
public function servico()
{
return $this->hasMany(Servico::class);
}
public function cliente()
{
return $this->hasOne(Cliente::class, 'id', 'cliente_id');
}
public function ordemservico()
{
return $this->hasOne(OrdemServico::class);
}
Repository
public function exibir($id)
{
$orcamento = Orcamento::where('id', $id)->with('cliente')->with('servico')->first();
return $orcamento;
}
In the related table with('servico'), the columns, "quantity, value_unitario(decimal:8,2)", "discount(decimal:8,2)" need to multiply quantity by value_unitario and subtract by discount if it exists, and sum all the total values, to show in the VIEW the total of each, and the total of all.
top understood, I’ll adapt to my code, thanks bro
– MichaelCosta
Shooow man! Anything we are there.
– Aguinaldo Tupy