Bonehead question: how to escape eloquent query with raw()

I’m writing some complex queries using Eloquent and I need to escape some queries using raw. Examples from Laravel are using using the following construct to escape a query using raw();


However, for the life of me I can’t seem to figure out the correct namespace/path to access a proper raw() function (given that the above is for a Laravel-specific context). Can someone please point me in the right direction?

To clarify, I know how to do a raw where clause or an entire raw query, but I have no idea how to escape a single where parameter using raw(). For reference, want to escape the $uid parameter in the following query (because Eloquent insists on using the value of $uid as a column name):

$wallets = self::where('sequence', '=', $sequence)->where('interval', '=', $minutes)
        ->leftJoin('wallet', 'wallet_stats.wallet_id', '=', '')
        ->leftJoin('balance', function($join) use ($uid)
            $join->on('balance.wallet_id', '=', 'wallet_stats.wallet_id')
                 ->on('balance.user_id', '=', $uid);
        ->orderBy($sort, 'ASC')->get(['symbol', 'name', 'volume', 'start_price', 'end_price']);

Thanks for any pointers.

I hate do do this, but I’ll put a ‘ping’ here because I’m still stuck on this one. Any hints are appreciated.

You can do this using a Capsule static method.



Thank you very much. :grinning: