jeudi 11 février 2016

L5.1: Casting parameters as INT before query works in one server, not the other

I'm working with Laravel 5.1 and I have defined relationships in my models appropriately. When I do:

$warehouses = Auth::user()->warehouses
->where('activity_id', $request->activity_id)
->where('company_id', $request->company_id);

I get a result in my local server, but an empty collection in testing server. I learned that if I do this:

$company_id = (int)$request->company_id;
$activity_id = (int)$request->activity_id;
$warehouses = Auth::user()->warehouses
->where('activity_id', $activity_id)
->where('company_id', $company_id);

I get an empty collection in my local server but I get results in testing server. Is this a configuration thing? I don't remember changing anything related to this. Is it MySQL related? Testing database is a dump from local database and id fields are integer, auto increment and unsigned. I'd appreciate any help



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire