Search code examples
phplaravelrepositorylaravel-5.3eloquent

How to solve Type error: Argument 1 passed to Rinvex\Repository\Repositories\EloquentRepository::findWhereNotIn() must be of the type array?


My query is like this :

$this->user_repository->findWhereNotIn('id', [1, 2, 3, 4]);

When executed, there exist error like this :

[Symfony\Component\Debug\Exception\FatalThrowableError] Type error: Argument 1 passed to Rinvex\Repository\Repositories\EloquentRepository::findWhereNotIn() must be of the type array, string given, called in C:\xampp\htdocs\myshop\app\Console\Commands\Check.php on line 48

Whereas in the tutorial https://github.com/rinvex/repository#findwherenotin, it looks like my query is correct

How can I solve it?


Solution

  • You're passing column name as string in first parameter, then values as an array in second parameter, while the correct syntax for rinvex/repository findWhereNotIn as per the docs is passing both column name and values to the first parameter as an assosiative array as follows:

    $repository->findWhereNotIn(['id', [1, 2, 5, 8]]);
    

    Notice how they're passes: ['id', [1, 2, 5, 8]]