Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

muazzamazaz's avatar

The PUT method is not supported for this route. Supported methods: GET, HEAD, POST.

Using following code:

Blade:

{!! Form::model($commission, array('action' => array('CommissionController@update', $commission->id), 'method' => 'PUT')) !!}

web.php

 Route::resource('commissions', 'CommissionController', [
        'names' => [
            'index'   => 'commissions',
            'destroy' => 'commissions.destroy',
        ],
    ]);

Controller

public function update(Request $request, $id)
    {
        
        $commission = Commission::find('destination_id',$id);

        $input = Input::only('destination_id','effective_date', 'ticketPrice','commPercentage');       
     
        $commission->fill($input)->save();

        return redirect('commissions/'.$destination->id)->with('success', trans('commission.updateSuccess'));
    }
0 likes
11 replies
foram's avatar

https://laravel.com/docs/5.8/routing#form-method-spoofing

HTML forms do not support PUT, PATCH or DELETE actions. So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to add a hidden _method field to the form. The value sent with the _method field will be used as the HTTP request method:

<form action="/foo/bar" method="POST">
    <input type="hidden" name="_method" value="PUT">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
muazzamazaz's avatar
{!! Form::model($destination, array('action' => array('DestinationController@update', $destination->id),'enctype'=>'multipart/form-data', 'method' => 'PUT')) !!}

This similar code is working fine with route:

Route::resource('destinations', 'DestinationController', [
        'names' => [
            'index'   => 'destinations',
            'destroy' => 'destinations.destroy',
        ],
    ]);

The difference is that $commission being used in model has a join relation with destination model.

$commission = Commission::join('destinations', 'id', '=', 'destination_id')   
    ->select('destination_id','location','name','effective_date', 'ticketPrice','commPercentage')->where('id','=',$id)->first();

tisuchi's avatar

@MUAZZAMAZAZ - Just explaining @foram idea a bit.

You just add PUT hidden field after declaring form tag like this-

{!! Form::model($destination, array('action' => array('DestinationController@update', $destination->id),'enctype'=>'multipart/form-data', 'method' => 'POST')) !!}

<input type="hidden" name="_method" value="PUT">

.
.
.

foram's avatar

@muazzamazaz You have set method as POST

but pass PUT as below in your form

 <input type="hidden" name="_method" value="PUT">
muazzamazaz's avatar

@foram

Same error with this code

 {!! Form::model($commission, array('action' => array('CommissionController@update', $commission->id), 'method' => 'POST')) !!}

                        {!! csrf_field() !!}
<input type="hidden" name="_method" value="PUT">
muazzamazaz's avatar
muazzamazaz
OP
Best Answer
Level 2

There was a mistake in form model array id field $commission->id to $commission->destination_id

4 likes
onyashed's avatar

I had a similar issue. But I realized there is a difference between.

{!! Form::open(['action' => ['PostsController@update', $post->id]) !!}
    {{Form::hidden('_method','PUT')}}

and

 {!! Form::model(['action' =>[ 'PostsController@update', 'id' => $post->id],'method'=>"POST"]) !!}
{{Form::hidden('_method','PUT')}}

The Form::open() works but Form::model() fails but also on laravel 5.8


        @method('PATCH') 

is the alternative of the form hidden segment. What is the issue with gates @muazzamazaz ?? I'm new in this and would like to avoid messy code...

onyashed's avatar

The Form::open works but Form::model fails

Please or to participate in this conversation.