В моем настольном приложении есть синтаксис SQL, который я хочу использовать в своем проекте Laravel.
select case when CustomerOrder.cv_id <> ''
then d.NamaCustomer else Customer.NamaCustomer end CustName,
case when CustomerOrder.cv_id <> '' then d.CustomerId else Customer.CustomerId end IDCsst,
CustomerOrder.CustomerOrderNo, CustomerOrder.dt_create, CustomerOrder.dt_approve1, CustomerOrder.dt_approve2, CustomerOrder.dt_release, CustomerOrder.ship_flag
FROM CustomerOrder
LEFT OUTER JOIN mst_membercard
ON CustomerOrder.CustomerId = mst_membercard.customerid
INNER JOIN Customer
ON CustomerOrder.CustomerId = Customer.CustomerId
LEFT OUTER JOIN Customer d
ON CustomerOrder.cv_id = d.CustomerId
WHERE CustomerOrder.ord_type in ('','O','T','B','G') ORDER BY CustomerOrder.dt_create DESC
и я пытаюсь использовать это
$CustOrd = CustomerOrderModel::selectRaw('case when CustomerOrder.cv_id <> "" then Customer.NamaCustomer else Customer.NamaCustomer end as CustName, case when CustomerOrder.cv_id <> "" then Customer.NamaCustomer else Customer.NamaCustomer end as CustName, CustomerOrder.CustomerOrderNo, CustomerOrder.dt_create, CustomerOrder.dt_approve1, CustomerOrder.dt_approve2, CustomerOrder.dt_release, CustomerOrder.ship_flag')
->join('mst_membercard', 'CustomerOrder.CustomerId', '=', 'mst_membercard.CustomerId')
->join('Customer', 'CustomerOrder.CustomerId', '=', 'Customer.CustomerId')
->Leftjoin('Customer d', 'CustomerOrder.cv_id', '=', 'd.CustomerId')
все еще ошибка.