1

I have a form in Laravel5

<form method="POST" action="http://localhost:8000/song/Baby/update" accept-charset="UTF-8">
    <input name="_method" type="hidden" value="PATCH">
    <input name="_token" type="hidden" value="kagIHsGe3zOZSPVyW6wW84Cn5eresZ2nlF287nNK">
    <div class="form-group">
        <input class="form-control" name="title" type="text" value="Baby">
    </div>
    <div class="form-group">
        <textarea class="form-control" name="lyrics" cols="50" rows="10">
            Yo Yo Yo BABY
        </textarea>
    </div>
    <div class="form-group">
        <input type="submit" value="Update Song">
    </div>        
</form>

Then in Route file I have written the code

patch('songs/Baby/update','SongsController@update');

Its throwing error

Sorry, the page you are looking for could not be found.

NotFoundHttpException in RouteCollection.php line 143:

Is the syntax changed for PATCH request in Laravel 5?

Wtower
  • 18,848
  • 11
  • 103
  • 80
Vikram Anand Bhushan
  • 4,836
  • 15
  • 68
  • 130

2 Answers2

2

Your route and form action are different.

You have defined a route with songs (plural) and used as song (singular) in form action.

Try changing your form action to

action="http://localhost:8000/songs/Baby/update"
chanafdo
  • 5,016
  • 3
  • 29
  • 46
1

Try this: <input type="hidden" name="_method" value="PUT"> and Route::put('songs/Baby/update','SongsController@update').

CrackingTheCode
  • 802
  • 1
  • 11
  • 26