У меня есть запрос sql, и я хочу изменить на laravel Запрос
Это sql
SELECT
products.id,
products.name,
(select ifnull(sum(stocks.qty),0) from stocks where stocks.pid=products.id and DATE(stocks.created_at)
= CURDATE()) as stock_in_today,
(select ifnull(sum(loadings.qty),0) from loadings where loadings.pid=products.id and
DATE(loadings.created_at) = CURDATE()) as total_loadings_today,
(select ifnull(sum(stocks.qty),0) from stocks where stocks.pid=products.id) as total_stock_till_date,
(select ifnull(sum(loadings.qty),0) from loadings where loadings.pid=products.id) as
total_loadings_till_date,
((select ifnull(sum(stocks.qty),0) from stocks where stocks.pid=products.id and
DATE(stocks.created_at) < CURDATE())-(select ifnull(sum(loadings.qty),0) from loadings where
loadings.pid=products.id and DATE(loadings.created_at) < CURDATE())) as opening_balance,
((select ifnull(sum(stocks.qty),0) from stocks where stocks.pid=products.id)-(select
ifnull(sum(loadings.qty),0) from loadings where loadings.pid=products.id)) as closing_balance
from products
кто-то может помочь в этом