【发布时间】:2022-01-27 02:29:37
【问题描述】:
mb_strpos() 期望参数 1 是字符串,给定对象 - 使用下面的查询在 eloquent 中使用 with 进行嵌套过滤来面对这个错误。
$columns = Column::with(['cards', function ($query) {
$query->where(function ($query) {
if (isset($_GET['status']) && $_GET['status'] != '') {
$query->where('status', trim($_GET['status']));
}
})
->where(function ($query) {
if (isset($_GET['date']) && $_GET['date'] != '') {
$query->where('created_at', trim($_GET['date']));
}
});
}])->get();
【问题讨论】:
-
mb_strpos()未出现在您发布的代码中,因此我们不知道此错误发生在哪里。不过,信息很明确。您正在向它发送一个对象并且它需要一个字符串。你应该能够解决这个问题。