[英]NotFoundHttpException at new route Laravel 4
i see there are similar questions but dont find any clue of me problem. 我看到有类似的问题,但没有发现我问题的任何线索。
I created a basic users system, to manage groups, permissions, users, etc. The basic routes like create, edit, delete, index are working. 我创建了一个基本的用户系统,用于管理组,权限,用户等。创建,编辑,删除,索引之类的基本路径都可以使用。
Now im trying to add one more function to UserController, to manage the users groups in a simple view. 现在,我正在尝试向UserController添加一个功能,以便在一个简单的视图中管理用户组。
Route::group(array('prefix' => 'admin'), function()
{
Route::resource('groups', 'GroupController');
Route::resource('users', 'UserController');
});
The function in controller: 控制器功能:
public function groups($id)
{
$user = Sentry::findUserByID($id);
$groups = $user->getGroups();
return View::make('users.show')
->with('groups', $groups);
}
And the users/groups.blade.php: 和users / groups.blade.php:
@extends('layouts.admin')
@section('content')
<header id="page-title">
<h1>User Groups</h1>
</header>
<!-- if there are creation errors, they will show here -->
{{ HTML::ul($errors->all()) }}
{{ Form::open(array('url' => 'admin/users/save_groups')) }}
<div class="form-group">
</div>
{{ Form::submit('Create!', array('class' => 'btn btn-primary')) }}
{{ Form::button('Cancel', array('class' => 'btn btn-danger')) }}
{{ Form::close() }}
@stop
I go to url " mysite/admin/users/2/groups
", and im getting the NotFoundHttpException
, i try many ways to make it works and dont know what is happening. 我去网址“
mysite/admin/users/2/groups
”,并获取NotFoundHttpException
,我尝试了多种方法使其工作并且不知道发生了什么。
I assume it will works like " mysite/admin/users/2/edit
", but if i test the show function, it only is " mysite/admin/users/2
", dont need the show action to know is that function, maybe i missed something. 我认为它的工作方式类似于“
mysite/admin/users/2/edit
”,但是如果我测试显示功能,则只能是“ mysite/admin/users/2
”,不需要显示操作即可知道该功能,也许我错过了一些东西。
You have declared a route for "GroupsController". 您已经为“ GroupsController”声明了一条路由。 As per the documentation , this will only handle actions as defined in the table: "Actions Handled By Resource Controller"
根据文档 ,这将仅处理表中定义的操作:“资源控制器处理的操作”
Just by adding one more action it won't simply be extended by Laravel. 只需再添加一个动作,Laravel就不会简单地对其进行扩展。 You should instead type:
您应该输入:
Route::get('users/{id}/groups', 'UserController@groups');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.