Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given
Argument 1 passed to IlluminateDatabaseQueryBuilder::cleanBindings() must be of the type array, null given
In this session, we are going to try to solve the "Argument 1 passed to IlluminateDatabaseQueryBuilder::cleanBindings() must be of the type array, null given" puzzle by using the computer language.
Sometimes we get error Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given because we passed value to the query which is not in array format.-
WhereNotIn() query example in laravel
--PATH routes\web.phpRoute::get('/whereNotIn-with-array', function(){ $usersIdArray = array('1', '2', '3'); $users = App\Models\User::whereNotIn('id', $usersIdArray)->get(); return $users; });
You can check the variable before passing to the whereNotIn(). If the type of $array variable is not an array then you can convert it to an array and also pass an empty array if you don’t want to pass any data to it.
It will return all the records (user) from users table except the user which has id 1, 2, 3.
-
Pass null argument to WhereNotIn() query
--PATH routes\web.php//Code with error - to see the error message Route::get('/whereNotIn-with-null', function(){ $usersId = null; $users = App\Models\User::whereNotIn('id', $usersId)->get(); });
It will return Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Call to undefined method App\Models\User::follow()
- How to fill a column automatically while creating records in Laravel
- How to get specific columns using with method in laravel Eloquent relationship
- How to pass query string to url in laravel
- JQuery each loop on json response after ajax in laravel
- Insert values in pivot table dynamically in laravel
- How to check data inserted or deleted in pivot after toggle method
- Create user in Laravel using tinker
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- How to send email in Laravel 11
- How to generate .env file for laravel?
- Generate random string lowercase in Laravel
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
- The openssl extension is required for SSL/TLS protection but is not available
- File_put_contents(/var/www/html/w3code/storage/framework/sessions/CXwN3EXKxERD6jgy3rADcaAAbAx8FRKih2JK7UO9): Failed to open stream: Permission denied
- Route not defined in Laravel
- Get content from web URL in laravel
- How to add script on specific view file in laravel while extending layout
- Laravel form request validation
- How to remove package from laravel
- Laravel append URI in route
- Illuminate\Database\QueryException could not find driver
- Convert multidimensional array to single array in Laravel
- Get id of last inserted record in laravel
- Return redirect laravel not working