不久前,它的工作非常精致和完美,然后我不得不去添加分页,我搞砸了一些东西,现在我不能,为了我的生活,弄清楚我已经破坏了什么。
所以得到这个:
我有两条路线,dashboard/applications
和dashboard/applications/filter
在应用程序页面上,输入搜索/过滤器值,然后将其作为GET提交到过滤器页面,以便您可以过滤应用程序
但现在它不断地将我重定向到应用程序页面,甚至没有触及控制器功能。
我正在失去理智。
路由
// Applications
Route::get('dashboard/applications', array(
'as' => 'dashboard.applications',
'uses' => 'DashboardController@applications'
));
Route::get('dashboard/applications/filter', array(
'as' => 'dashboard.applications.filter',
'uses' => 'DashboardController@applicationsFilter'
));
Route::get('dashboard/applications/{id}', array(
'as' => 'dashboard.applications.view',
'uses' => 'DashboardController@applicationsView'
));
DashboardController
/**
* Manage user applications
*/
public function applications()
{
$perPage = 10;
return View::make('dashboard.applications', array(
'applications' => Application::orderBy('id', 'desc')->paginate($perPage)
));
}
/**
* Filter applications
* By date range, customer, company, email and payment status
*/
public function applicationsFilter()
{
return 'test!';
// filter code here
}
查看
{{ Form::open(array('route' => 'dashboard.applications.filter', 'method' => 'get')) }}
// form inputs, textares etc
{{ Form::close() }}
现在肯定,当我至少访问过滤器页面时它应该返回test!
,但是没有。它只是将我重定向回应用程序页面。我很抱歉,如果这真的很愚蠢,我忽略了一些简单的事情,但我现在已经过了大约30次
答案 0 :(得分:1)
'dashboard/applications/filter'
是否覆盖了'dashboard/applications/{id}'
?在第一次匹配后,第二次匹配。
尝试将其更改为此内容,并查看其是否有效:
// Applications
Route::get('dashboard/applications', array(
'as' => 'dashboard.applications',
'uses' => 'DashboardController@applications'
));
Route::get('dashboard/applications/filter', array(
'as' => 'dashboard.applications.filter',
'uses' => 'DashboardController@applicationsFilter'
));
Route::get('dashboard/application/{id}', array(
'as' => 'dashboard.applications.view',
'uses' => 'DashboardController@applicationsView'
));