For one of the resources of my laravel application, I get an error when leaving a field blank:
Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, null given, called in /var/www/html/pfladmin/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 309 and defined
I looked in the stack trace for some code that I'd written (as opposed to coming from the laravel framework) and the only one was the controller for the resource, which pointed me to the following line.
$servicesFacilities =
DB::table('services_facilities')->whereIn('services_facilities_id',
Input::get('services_facilities'))->lists('name');
I get that this has something to do with my passing a NULL around and this causing problems all over the stack trace, but why would that be happening here when it isn't happening for other fields that are allowed to be left blank?
I get that this has something to do with my passing a NULL around and this causing problems all over the stack trace, but why would that be happening here when it isn't happening for other fields that are allowed to be left blank?
I couldn't say for sure, but my guess is you're not using the other fields in a whereIn query.
$servicesFacilities =
DB::table('services_facilities')->whereIn('services_facilities_id',
Input::get('services_facilities')
)->lists('name');
The whereIn method expects the second parameter to be an array. i.e., something like this
DB::table('services_facilities')->whereIn('services_facilities_id',
[1,2,3]
)
Your error message is complaining about something not being an array
Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, null given,
The quick fix would be something like
//$ids = Input::get('services_facilities') ? Input::get('services_facilities') : [];
$ids = Input::get('services_facilities', [])
...
DB::table('services_facilities')->whereIn('services_facilities_id',
$ids
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With