
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
- Use withCount() to Calculate Child Relationship Records
- Route group with URI prefix using middleware and route name prefixes
- Use withCount() to get total number of records with relationship
- Undefined property: stdClass::$title
- Create user in Laravel using tinker
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- How to generate .env file for laravel?
- How to use or operator in laravel
- Cast Array to an Object in Controller and then pass to view in laravel
- Create model with migration and seeder
- How to upload image in laravel 8
- Return redirect laravel not working
- Update existing pivot table data in laravel
- Call to a member function getRelationExistenceQuery() on array in Laravel
- How to call model in blade laravel
- Laravel specific table Migration
- Extra Filter Query on Relationships in Laravel
- Get content from web URL in laravel
- Laravel create multiple records in Pivot table
- How to validate URL with https using regex in laravel
- How to get all route list
- Get current URL on visit URL in Laravel
- How to include header file in laravel
- Laravel API response format
- How to run a specific seeder class in laravel