如何解决类型错误:传递给Rinvex \ Repository \ Repositories \ EloquentRepository :: findWhereNotIn()的参数1必须是类型数组?

问题描述:

我的查询是这样的:如何解决类型错误:传递给Rinvex Repository Repositories EloquentRepository :: findWhereNotIn()的参数1必须是类型数组?

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

执行时,存在误差是这样的:

[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

而在本教程https://github.com/rinvex/repository#findwherenotin,它看起来像我的查询是正确的

哪有我解决了它?

+0

'参数1'是指'id'不是阵列 – Machavity

+0

尝试使用'['id']'而不是 – Onix

+0

@Onix,它不起作用。有错误:'[ErrorException] 为foreach()提供的无效参数' –

你在第一个参数传递列名作为字符串,则值作为第二个参数数组,而rinvex/repositoryfindWhereNotInas per the docs正确的语法都通过列名和值第一个参数为assosiative阵列如下:

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

通知他们是如何通过是:[ 'ID',[1,2,5,8]]

+0

太好了。有用。谢谢 –

+0

也许你可以帮助我。看看这个:http://*.com/questions/43326809/how-to-solve-missing-argument-3-for-rinvex-repository-repositories-baserepositor –