vendredi 20 mai 2016

Complicated Laravel Query

I want to convert the following SQL query to Laravel Eloquent or Query

SELECT
    SUM(T1.total) AS Total,
    SUM(T1.received) AS Received,
    T1.EventName,
    T1.CurrencyType
FROM
    (
        SELECT
            event_invoice.Id,
            event_invoice.Amount AS total,
            SUM(payments.recieved_amount + payments.adjust_amount) AS received,
            event_invoice.EventName,
            event_invoice.CurrencyType
        FROM
            event_invoice
        LEFT JOIN payments ON event_invoice.Id = payments.invoice_id
        GROUP BY
            event_invoice.Id
        ORDER BY
            event_invoice.Id
    ) T1
GROUP BY
    T1.EventName,
    T1.CurrencyType

I wanted to convert into Laravel any Ideas ??



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire