Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Tesoro's avatar

Laravel Query Doesn't Retrive the given value

I got an random array instead of value am actually passed on where condition,

my Actual query is

$data = Dataimp::where('name','Tesoro');

dd($data->toSql(),$data->getBindings());

My Raw Query & Binding data is as follows

"select * from "data_dial" where "name" = ?" Builder {#373 #passthru: array:12 [] #query: Builder {#371 } #model: Dataimp {#360 } #eagerLoad: [] #localMacros: [] #onDelete: null #scopes: [] #removedScopes: [] }

Suggest some idea for this Issue...

0 likes
4 replies
Nakov's avatar

No it is not a random array, the result is a Query Builder when you don't call get or first on it, so try one of this instead:

$data = Dataimp::where('name','Tesoro')->get(); // collection of datas

// or
$data = Dataimp::where('name','Tesoro')->first(); // the first row found
Mahaveer's avatar

@tesoro

If you recently deployed you project to your production server or moved the project to another server, do not forget to clear the app cache by running these commands.

php artisan cache:clear
php artisan view:clear
php artisan config:cache

it should fix it.

Also consider updating your .env file to match new environment variables.

Tesoro's avatar

Actually i removed get to use toSql()....

If i use like this $data = Dataimp::where('name','Tesoro')->get();

it returns boolean values

Nakov's avatar

@TESORO - Can you please try it out and share the result here? Because what you are saying does not make sense to me.

Please or to participate in this conversation.