“MethodNotAllowedHttpException”从Laravel 5.2更新中重新调整

时间:2016-05-21 17:40:25

标签: php laravel laravel-5.2

我在Laravel 5.2中更新表单时重新调整了MethodNotAllowedHttpException。我知道put方法可能存在问题。

从索引发送的表单:

{!! Form::model('Customers', ['route'=>['products.update', Auth::user()->id]]) !!}

{{ Form::hidden('business', Auth::user()->name, array('class' => 'form-control', 'required' => '','maxlength'=>'255'))}}


{{ Form::label('post', 'Mailbox')}}
{{ Form::checkbox('post',1, null, array('class' => 'form-control'))}}

控制器是:

  public function update(Request $request, $id)
    {
       $this->validate($request, array (
            'post' => '',
            'mailbox' => '',
            'conum' => '',
            'prefix' => '',
            'telans' => '',
            'TC' => 'required',

        ));

        //store
        $post = Customers::find($id);



        $post->post = $request->input('post');
        $post->postpro = $request->input('mailbox');
        $post->telans = $request->input('telans');
        $post->conum = $request->input('conum');
        $post->prefix = $request->inut('prefix');
        $post->tc = $request->input('TC');

        //save
        $post->save();

        //session flash message
        //Session::flash('success','This customer has now been added');

        //redirect
return redirect('/home');}

路线如下:

  Route::resource('products', 'ProductsController');

谢谢

1 个答案:

答案 0 :(得分:1)

你忘记了引号,取而代之:

<强> PHP

$post->post = $request->input(post);

用这个:

$post->post = $request->input('post');

不要忘记将_method设置为put。