Laravel 未定义路由[名称]。拉维4.1
我在Laravel4.1中遇到了一些路由问题 我在url:/AppFastFood/webapp/public/users/profile上有一个页面 谁负责编辑和更新当前用户 我有一个管理用户的页面,索引在url上工作得很好: /AppFastFood/webapp/public/users 仅更改用户角色的页面为/AppFastFood/webapp/public/users/1/edit 无法显示此页面,我有以下错误: 未定义路由[users.updaterole]。视图:C:\wamp\www\AppFastFood\webapp\app\views\users\edit.blade.phpLaravel 未定义路由[名称]。拉维4.1,laravel,laravel-routing,Laravel,Laravel Routing,我在Laravel4.1中遇到了一些路由问题 我在url:/AppFastFood/webapp/public/users/profile上有一个页面 谁负责编辑和更新当前用户 我有一个管理用户的页面,索引在url上工作得很好: /AppFastFood/webapp/public/users 仅更改用户角色的页面为/AppFastFood/webapp/public/users/1/edit 无法显示此页面,我有以下错误: 未定义路由[users.updaterole]。视图:C:\wamp\
@section('content')
<h1>Edit {{ $user->firstname }}</h1>
<!-- if there are creation errors, they will show here -->
{{ HTML::ul($errors->all()) }}
{{ Form::model($user, array('route' => array('users.updaterole', $user->id), 'method' => 'PUT')) }}
<div class="form-group">
{{ Form::label('fk_role', 'Role') }}
{{Form::select('fk_role',$roles, $user->fk_role, array('class' => 'form-control')) }}
</div>
{{ Form::submit('Edit the user !', array('class' => 'btn btn-primary')) }}
{{ Form::close() }}
@stop
有人能帮我吗
这是我的代码:
routes.php
<?php
Route::get('/', function()
{
return Redirect::to('/users/dashboard');
});
//Users
Route::get('users/{all}/edit', 'UsersController@edit');
Route::post('users/{all}', 'UsersController@updaterole');
Route::controller('users', 'UsersController');
//Password
//Route::controller('password', 'RemindersController');
// Routes Users
Route::get('/remind','RemindersController@getRemind');
Route::post('/remind','RemindersController@postRemind');
Route::get('/password/reset/{token}','RemindersController@getReset');
Route::post('/password/reset','RemindersController@postReset');
//requière un login
Route::group(array('before' => 'auth'), function () {
// Routes POI
Route::resource('pois', 'PoiController');
Route::resource('categories', 'CategoryController');
Route::resource('users', 'UsersController');
//Route::resource('users.updaterole', 'UsersController@updaterole');
});
edit.blade.php
@section('content')
<h1>Edit {{ $user->firstname }}</h1>
<!-- if there are creation errors, they will show here -->
{{ HTML::ul($errors->all()) }}
{{ Form::model($user, array('route' => array('users.updaterole', $user->id), 'method' => 'PUT')) }}
<div class="form-group">
{{ Form::label('fk_role', 'Role') }}
{{Form::select('fk_role',$roles, $user->fk_role, array('class' => 'form-control')) }}
</div>
{{ Form::submit('Edit the user !', array('class' => 'btn btn-primary')) }}
{{ Form::close() }}
@stop
路线:
您的路线申报有问题。您已使用相同的url和控制器名称声明了两条路由,如下所示:
Route::controller('users', 'UsersController');
Route::resource('users', 'UsersController');
使用任何一个。在php artisan routes命令的结果中,没有在表单中用作操作的路由,而是users.updaterole.update。尝试使用任何一个或将其中一个重命名为其他路由和控制器。谢谢,我修复了以下路由的问题:
Route::get('usersadmin/{all}/edit', 'UsersController@edit');
Route::get('usersadmin.update', 'UsersController@update');
Route::post('usersadmin/{all}', 'UsersController@update');