我是新的 laravel 5.3,并且面临着 eloquent 的子查询问题。我不知道如何使用 eloquent 编写子查询。我的查询如下。
select concat(m, '-', y), total
FROM (
select month(`date`) as m , year(`date`) as y, round(sum(amount)) as total
from `budget`
where
`user_id` = 1 and
`amount` is not null
group by m, y
) as t
这在 MySQL 中运行良好。那么我们如何才能将这个查询转换成 eloquent。所以请解决这个问题