Thursday, March 30, 2017

Calculated fields in Laravel using ORM

I've been working in a Laravel Project and I have this doubt. How may I show a calculated field in a blade view? I want to retrieve some information from an invoice and a Total calculated field.

I would like to get this result, but using Eloquent ORM. The query is this:

   SELECT invoiceheader.id, invoiceheader.customerlastname,
   invoiceheader.customerfirstname, invoiceheader.customernit, 
   invoicedetail.productid, invoicedetail.quantity, 
   invoicedetail.saleprice, (quantity * saleprice) as Total
   FROM invoiceheader inner join invoicedetail
   ON invoiceheader.id = invoicedetail.invoiceid

Thank you so much in advance.



via krlosfgx

Advertisement