0
所以即時通訊嘗試使用多個參數進行查詢,從表單中產生一個屬性搜索方法。但我一直在努力與我的showResults
方法,因爲我不斷得到Missing argument 1 for IndexController::showResults()
。另外,我想確保如何通過屬性和類別之間的多對多關係進行搜索。 categories[]
是我的表單中的選擇倍數。索引控制器在搜索查詢中缺少參數1 Laravel
這是我的代碼到目前爲止。
Route::get('buscar/propiedades', array('as' => 'search', 'uses' => '[email protected]'));
Route::post('buscar/propiedades', array('as' => 'search', 'uses' => '[email protected]'));
public function showResults($categories, $activity, $currency, $beds, $baths, $price)
{
return View::make('front.results')
->with('properties', Property::join('category_property', 'properties.id', '=', 'category_property.property_id')
->join('categories', 'category_property.category_id', '=', 'categories.id')
->join('activities', 'activities.id', '=', 'properties.activity_id')
->join('currencies', 'currencies.id', '=', 'properties.currency_id')
->whereIn('categories.id', $categories)
->orWhere('activities.id', '=', $activity)
->orWhere('currencies.id', '=', $currency)
->orWhere('properties.beds', '=', $beds)
->orWhere('properties.baths', '=', $baths)
->orWhere('properties.price', '=', $price)
->paginate(6);
}
public function searchProperties()
{
$validator = Validator::make(Input::all(), Property::$search_rules);
// if the validator fails, redirect back to the form
if ($validator->fails()) {
return Redirect::to('/')
->withInput(); // send back the input (not the password) so that we can repopulate the form
}else{
$categories = Input::get('category_id');
$activity = Input::get('activity_id');
$currency = Input::get('currency_id');
$beds = Input::get('beds');
$baths = Input::get('baths');
$price = Input::get('price');
}
$this->showResults($categories, $activity, $currency, $beds, $baths, $price);
return Redirect::to('buscar/propiedades');
}
驗證是正確的..沒有問題 – 2014-10-09 17:43:03
什麼是錯誤或邏輯問題呢? – 2014-10-09 17:50:19
所有變量都正確輸出。問題出在我猜的查詢中。 $ categories是一個數組,我不知道它是否導致錯誤 – 2014-10-09 17:53:18