0
私は、このクエリLaravelのリレーションシップ列でフィルタリングするにはどうすればよいですか?
public function index()
{
$properties = PropertyDetail::query()->with('propLocation');
$properties->where('type', Input::get('unitType'));
$properties->where('purpose', Input::get('purpose'));
$properties->where('active', 1);
if (Input::has('specifyType')) {
$properties->where('specify_type', Input::get('specifyType'));
}
if (Input::has('location')) {
$properties->where('state', Input::get('location'));
}
$result = $properties->get();
return View::make('portal.properties.view', compact('result'));
}
propLocation
は今、私はそこの統計値を検索することができますどのように私の第二のテーブルである必要があり、これが行われる必要がありますどのように ?
if (Input::has('location')) {
$properties->where('state', Input::get('location'));
}
が、それは動作しません:
は、私はこれを試してみました。列は、あなたがそのような関係の列をフィルタリングすることはできません
あなたが何列が欠落しています
は次のように試してみてください? – GiamPy
'state'それは2番目のテーブルにあります' propLocation' witch私は ' - > with( 'propLocation')' –