拉威尔PHP 4:';把';方法生成';方法不允许HttpException';

拉威尔PHP 4:';把';方法生成';方法不允许HttpException';,php,laravel-4,Php,Laravel 4,我正在尝试修改用于编辑和更新数据的表单。然而,当我尝试提交“编辑”表单时,我总是得到一个“MethodNotAllowedHttpException”。我不确定这是因为我不正确地使用了“PUT”方法,还是因为我的“EditAlbumsController.php”文件定义不正确 编辑album.blade.php: {{ Form::model($album, array('method' => 'PUT', 'route' => array('edit_album', $album

我正在尝试修改用于编辑和更新数据的表单。然而,当我尝试提交“编辑”表单时,我总是得到一个“MethodNotAllowedHttpException”。我不确定这是因为我不正确地使用了“PUT”方法,还是因为我的“EditAlbumsController.php”文件定义不正确

编辑album.blade.php:

{{ Form::model($album, array('method' => 'PUT', 'route' => array('edit_album', $album->album_id))) }}
/* Form code here */
{{ Form::close() }}
Route::get('gallery/album/{id}/edit', array('as'=>'edit_album', 'uses'=>'EditAlbumsController@update'));
class EditAlbumsController extends AlbumsController {

public function __construct() 
{
    parent::__construct();
}

public function update($id)
{
    $input = \Input::except('_method');

    $validation = new Validators\Album($input);

    if ($validation->passes())
    {
    $album = Album::find($id);
    $album->album_name = $input['album_name'];
    /* Additional database fields go here */
    $album->touch();
    return $album->save();

    return \Redirect::route('gallery.album.show', array('id' => $id));
    }
    else
    {
        return \Redirect::route('gallery.album.edit', array('id' => $id))
        ->withInput()
        ->withErrors($validation->errors)
        ->with('message', \Lang::get('gallery::gallery.errors'));
    }
}    
routes.php:

{{ Form::model($album, array('method' => 'PUT', 'route' => array('edit_album', $album->album_id))) }}
/* Form code here */
{{ Form::close() }}
Route::get('gallery/album/{id}/edit', array('as'=>'edit_album', 'uses'=>'EditAlbumsController@update'));
class EditAlbumsController extends AlbumsController {

public function __construct() 
{
    parent::__construct();
}

public function update($id)
{
    $input = \Input::except('_method');

    $validation = new Validators\Album($input);

    if ($validation->passes())
    {
    $album = Album::find($id);
    $album->album_name = $input['album_name'];
    /* Additional database fields go here */
    $album->touch();
    return $album->save();

    return \Redirect::route('gallery.album.show', array('id' => $id));
    }
    else
    {
        return \Redirect::route('gallery.album.edit', array('id' => $id))
        ->withInput()
        ->withErrors($validation->errors)
        ->with('message', \Lang::get('gallery::gallery.errors'));
    }
}    
EditAlbumsController.php:

{{ Form::model($album, array('method' => 'PUT', 'route' => array('edit_album', $album->album_id))) }}
/* Form code here */
{{ Form::close() }}
Route::get('gallery/album/{id}/edit', array('as'=>'edit_album', 'uses'=>'EditAlbumsController@update'));
class EditAlbumsController extends AlbumsController {

public function __construct() 
{
    parent::__construct();
}

public function update($id)
{
    $input = \Input::except('_method');

    $validation = new Validators\Album($input);

    if ($validation->passes())
    {
    $album = Album::find($id);
    $album->album_name = $input['album_name'];
    /* Additional database fields go here */
    $album->touch();
    return $album->save();

    return \Redirect::route('gallery.album.show', array('id' => $id));
    }
    else
    {
        return \Redirect::route('gallery.album.edit', array('id' => $id))
        ->withInput()
        ->withErrors($validation->errors)
        ->with('message', \Lang::get('gallery::gallery.errors'));
    }
}    

非常感谢您的帮助

您需要定义PUT路由(您没有正确使用GET)