ana bel
ana bel

Reputation: 187

put is not supported for this route

i'm working on a crud app to learn laravel i'm doing good so far , other than when i want to update a post it gives me this put method is not supported for this route

@extends ('layouts.app')


@section('content')

<form action="{{route('update_blog_path',['blog'=>$blog->id])}}" method="POST">
@method('PUT')
    @csrf
<div class="form-group">
<label for="title">Title </label>
<input type="text" name="title" class="form-control" value={{$blog->title}}>
</div>
<div class="form-group">
<label for="title">Content </label>
<input type="text" name="content" class="form-control" value={{$blog->content}}>
</div>
<div class="form-group">
<button type="submit" class="btn btn-outline-primary">Edit</button>
</div>
</form>
@endsection


<?php

Route::get('/', function () {
    return view('welcome');
});
Route::name('blogs_path')->get('/blogs','BlogController@index');
Route::name('create_blog_path')->get('/blogs/create','BlogController@create');
Route::name('store_blog_path')->post('/blogs','BlogController@store');
Route::name('blogs_path1')->get('/blogs/{id}','BlogController@show');
Route::name('edit_blog_path')->get('/blogs/{id}/edit','BlogController@edit');
Route::name('update_blog_path')->put('/blogs/{id}','BlogController@updtae');

Upvotes: 0

Views: 60

Answers (2)

Yusuf Onur Sari
Yusuf Onur Sari

Reputation: 444

Try please;

@extends ('layouts.app')

@section('content')

<form action="{{ route('update_blog_path', ['blog' => $blog->id]) }}" method="POST">
    @csrf
    {{ mehod_field("PUT") }}
<div class="form-group">
<label for="title">Title </label>
<input type="text" name="title" class="form-control" value={{$blog->title}}>
</div>
<div class="form-group">
<label for="title">Content </label>
<input type="text" name="content" class="form-control" value={{$blog->content}}>
</div>
<div class="form-group">
<button type="submit" class="btn btn-outline-primary">Edit</button>
</div>
</form>
@endsection

and

Route

<?php

Route::put('update_blog_path/{blog}', 'BlogController@update')->name("update_blog_path");

And your'e code wrong update term Route::name('update_blog_path')->put('/blogs/{id}','BlogController@updtae');

change update

Upvotes: 1

jverbys
jverbys

Reputation: 55

Looks like you have a typo in your routes file, change

Route::name('update_blog_path')->put('/blogs/{id}','BlogController@updtae');

to

Route::name('update_blog_path')->put('/blogs/{id}','BlogController@update');

You misspelled the method name update.

Upvotes: 1

Related Questions