The ability to receive, but not filtered data in the production version of the Slim application using Eloquent

I worked on Slim 2 and recently started deploying to a production server. So far, everything is working fine. I can log in, so I know that I'm just connecting to the database. He found out who I logged in to, knowing what permissions I have as this user. I have another table with several records. When I...

$collection = collect($app->item->where('user_id', $userId)->get()); 

and then...

 print_r($collection); 

on the production server, I see the entire collection, as on the development server, but when I add ...

 $pack = $collection->where('status', 1); 

and instead of printing the collection, try printing the package as ...

 print_r($pack); 

This message is being returned ...

 Illuminate\Support\Collection Object ( [items:protected] => Array ( ) ) 

where in the development version I get a filtered collection, as you would expect. How to change the code to work in development and production environments?

+7
eloquent slim
source share
3 answers

Most likely, you do not have records in the production database with status 1, and you have records with status 1 in development.

Check the database directly during production to verify.

+6
source share

Apparently the collection contains only strings or it will match the string ... it works!

 $pack = $collection->where('status', '1'); 
+2
source share

Check out the version of Eloquent. Before builds 5.3, strict comparison was used when using where() , and for use without using, you used whereLoose() , but by 5.3 where() is a free comparison, and whereStrict() is a call to a strict method.

+2
source share

All Articles