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