if($city!='Others'){
$posts = Post::orderby('id','desc')->where(['city'=>$city])->paginate(10);
}
else{
$posts = Post::orderby('id','desc')->whereNotIn(['city'=>'Lahore'])->paginate(10);
}
}
我现在要显示一些特定的数据
除之前显示的数据以外的其他数据。
首先,如果显示的是正常数据,而我试图显示其他部分的剩余数据。
最佳答案
WhereNotIn
将采用值array
您还需要在其中传递列名
if($city !='Others'){
$posts = Post::orderby('id','desc')->where(['city'=>$city])->paginate(10);
}
else{
$posts = Post::orderby('id','desc')->whereNotIn('city',['Lahore'])->paginate(10);
}