Laravel嵌套路线问题

Kbi*_*rjn 4 php nested-routes laravel laravel-4

我对Laravel 4,嵌套路由有问题.我可以显示创建方法表单但无法存储.这是代码,我只是说到了这一点.我有一个基本资源控制器和另一个嵌套控制器

This is in my Routes.php

Route::resource('profile','ProfileController');
Route::resource('profile.bands','BandsController');
Run Code Online (Sandbox Code Playgroud)

我不认为我必须在这里显示配置文件的代码,我将向您展示BandsController

public function create($profileId)
{
    return View::make('bands.create',['title' => 'Create Band Profile' , 'profileId' => $profileId]);
}
Run Code Online (Sandbox Code Playgroud)

如您所知,这只会显示表单.表格是:

{{Form::open( [ 'route' => ['profile.bands.create',$profileId]])}}
<input class="input" type="text" name="name" value="" />
<input class="input" type="text" name="city" value="" />
 <input type="submit" value="submit" />
    {{Form::close()}}
Run Code Online (Sandbox Code Playgroud)

现在,我不明白,当我在浏览器中查看时,表单操作url看起来不错,但是当我提交它时,我得到了,这个错误.

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

open: E:\server\www\gigmor.com\gigmor\vendor\laravel\framework\src\Illuminate\Routing\Router.php
    // The method not allowed exception is essentially a HTTP 405 error, so we
    // will grab the allowed methods when converting into the HTTP Kernel's
    // version of the exact error. This gives us a good RESTful API site.
    elseif ($e instanceof MethodNotAllowedException)
    {
        $allowed = $e->getAllowedMethods();

        throw new MethodNotAllowedHttpException($allowed, $e->getMessage());
    }
}
Run Code Online (Sandbox Code Playgroud)

我可能做错了什么?

Ant*_*iro 6

MethodNotAllowedHttpException意味着您使用的HTTP方法不正确.你在一条只接受GET的路线上使用POST.

在您的表单上,您必须使用该路线

profile.bands.store
Run Code Online (Sandbox Code Playgroud)

您的.create路线只是为了显示创建记录表单,发布它必须使用商店.

使用查看您的路线名称和方法

php artisan routes
Run Code Online (Sandbox Code Playgroud)