[英]Laravel eloquent where error with <>
I have query for where in native php 我有查询,其中在本地的PHP
where type <> 'point'
其中type <>'point'
and I try convert to eloquent laravel
我尝试转换为雄辩的
laravel
->with('payments',function($query){
$query->where('type','<>','point');
})
but it is showing error as follows: 但它显示错误如下:
mb_strpos() expects parameter 1 to be string, object given
mb_strpos()期望参数1是字符串,给定对象
If that is all you need to do with the query then you can just chain it like this: 如果您只需要查询,那么您可以像这样链接它:
->with('payments')->where('type', '<>', 'point') //chain more after this
Correct answer should be this if you are trying to filter payments where the type
is not equal to point
. 正确答案应该是这样 ,如果你试图过滤支付在
type
不等于point
。
to parse the dynamic parameters within query try this : 要解析查询中的动态参数,请尝试以下操作:
$string = 'points';
->with(['payments' => function ($query) use ($string) {
$query->where('type', '<>', $string);
}])
this will work!! 这会工作!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.