James Parsons James Parsons - 6 months ago 28
PHP Question

"MethodNotAllowedHttpException" retuned from Laravel 5.2 update

I am getting MethodNotAllowedHttpException retuned when updating a form in Laravel 5.2. I understand there could be an issue with the put method.

The form sending from the index:

{!! 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'))}}


The Controller is:

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');}


And the route is as follows:

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


Thank you

Answer

Your forgot the quotes, replace this :

PHP

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

with this :

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

do not forget to set the _method as put.