->where([
'er.id_user_request_to' => $nIdUser
])
->where(DB::raw('case WHEN ge.id_user IS NOT NULL THEN ge.id_user = '.$nIdUser.' ELSE 0 END'))
tried to print a query using following code
$qry = vsprintf(str_replace(array('%', '?'), array('%%', '"%s"'), $oEvents->toSql()), $oEvents->getBindings());
dd($qry);
This prints a query like
WHERE
(
`er`.`id_user_request_to` = "6")
AND(
CASE WHEN ge.id_user IS NOT NULL THEN ge.id_user = 6 ELSE 0 END
)
) **IS NULL**
Not getting from where it adds IS NULL at the end of the query
Replace your DB::raw with whereRaw
->where([
'er.id_user_request_to' => $nIdUser
])
->whereRaw(('case WHEN ge.id_user IS NOT NULL THEN ge.id_user = '.$nIdUser.' ELSE 0 END'))
I hope it help's
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With