I am having a issue where when i write out a eloquent query using a variable it is returning NULL but if i write out that variable value in text it returns data.
This is my code
$code = 'Test123';
LiveProducts::where('code', $code)->first();
When i dump that query out i get NULL, but if i type it out like this:
LiveProducts::where('code', 'Test123')->first();
Then it will return data from the database.
I have dumped out the variable and it is defiantly a string.
$uuid = '...'
, thenModel::where('uuid', $uuid)->first()
andModel::where('uuid', '...')->first()
both return the same single result (I don't have acode
column, but same idea)... I can't recreate this, and I have no idea why this would be an error in your code; that's the syntax I've been using for over a decade 😅 How are you outputting this?dd(LiveProducts::where(...)->first())
? Or some other method like the query logger? Did you try->toSql()
?LiveProducts::where('code', '=', $code)->first();
if you want directions on the upgrade to 11 feel free to reach out. It's pretty straight forward, but there's a couple nuances.->first()
and->get()
and same outcome. tried the->toSQL()
as well then inputted that directly into my database and worked fine. for the output i trieddd()
the code direct, they i assigned it to a variable anddd()
it as well. I am baffled!