【发布时间】:2020-07-15 21:51:44
【问题描述】:
我用 3 个输入进行搜索,然后输入可以为空
我从前端获取变量
$addressSearch = $request->json()->get('addressSearch');
$typeSearch = $request->json()->get('typeSearch');
$statusSearch = $request->json()->get('statusSearch');
我使用查询中的函数进行此搜索
$property = Property::where('id', '1')
->Where(function($query)
{
$query->Where('type',typeSearch)
->orWhere('status',$statusSearch)
->orWhere('street','LIKE',"% $addressSearch}%");
})
->get();
我得到这个错误:
消息:“未定义的属性:App\Http\Controllers\PropertyController::$typeSearch
变量正常接收值
【问题讨论】:
-
第 4 行的 typeSearch 应该有 $ 符号,还要检查哪一行错误是指的
-
是的,但一直给我发送未定义的变量:
标签: sql laravel where-clause