Laravel 5 MethodNotAllowedHttpException

1.4k views Asked by At

I am using a form with PATCH method and I have a button link(since i already have a submit button and using same form for both store and update) as

<a class="btn btn-default" href="{{ URL::to( 'pages/edit/' . $vehicle -> id) }}">EDIT</a>

And my route is

Route::patch('/pages/edit/{id}', ['uses' => 'VehicleProcessController@update']);

Controller

public function update($id)
{
     $vehicle = Vehicle::find($id);  

     $input = Input::all();

     $vehicle->update($input);

     return  $input;
}

When i click to link $input returns null and i am getting

MethodNotAllowedHttpException

I am trying to get familiar with L5, how can i fix this ? Any help would be appreciated.

1

There are 1 answers

2
ceejayoz On BEST ANSWER

Your <a> link will trigger a GET request, not a PATCH request. You can use JS to have it trigger a PATCH request, or use a <button> or <input type="submit"> to issue one.