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.
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.
Share Improve this question edited Mar 26 at 18:46 Tim Lewis 29.3k14 gold badges80 silver badges107 bronze badges Recognized by PHP Collective asked Mar 26 at 9:07 Adam AllenAdam Allen 2041 gold badge3 silver badges12 bronze badges 9
$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发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744156353a4560880.html