问题描述
我正在为以下功能添加一个搜索条件:
$propiedadesObtenidas = Property::search($request->get('ubicacion'))
->where('tipoDePropiedad_id','=',$tipoPropiedad_id[0])
->get();
我想再添加一个条件,类似于:
$propiedadesObtenidas = Property::search($request->get('ubicacion'))
->where('tipoDePropiedad_id',$tipoPropiedad_id[0])
**->where('categoria',$categoria_id)**
->get();
有可能吗?
解决方法
是的。
// This,as u mentioned,gonna work.
$propiedadesObtenidas = Property::search($request->get('ubicacion'))
->where('tipoDePropiedad_id','=',$tipoPropiedad_id[0])
->where('categoria',$categoria_id)
->get();
// This can also Work
$propiedadesObtenidas = Property::search($request->get('ubicacion'))
->where([
['tipoDePropiedad_id',$tipoPropiedad_id[0]]
['categoria',$categoria_id]
])
->get();
还有其他基于您想做的方法,但是以上是它们最简单的方法。
祝你好运。