keyword
发送到控制器时,刀片正常工作
$search_alls = DB::table($table)
->where('title', '=', $keyword)
->where('status','=',0)
->orderBy($wanttime_by, $wanttime_order)
->paginate(9);
当我不将keyword
发送到控制器时,刀片显示错误
$search_alls = DB::table($table);
if ($keyword) {
$search_alls->where('title', '=', $keyword);
}
$search_alls
->where('status','=',0)
->orderBy($wanttime_by, $wanttime_order)
->paginate(9);
刀片视图
{{ $search_all->id }}
错误消息是
未定义的属性:Illuminate \ Database \ MySqlConnection :: $ id
答案 0 :(得分:0)
$search_alls = DB::table($table);
if ($keyword) {
$search_alls=$search_alls->where('title', '=', $keyword);
}
$search_alls=$search_alls
->where('status','=',0)
->orderBy($wanttime_by, $wanttime_order)
->paginate(9);
谢谢@thisiskelvin!每个人都有帮助!