Home > front end >  iam updating my category and found error The PUT method is not supported for this route. Supported m
iam updating my category and found error The PUT method is not supported for this route. Supported m

Time:08-17

I Just wanna to creating some category(i am from indonesia). And i found a bug when i am just try updating my category.

This is my routes

routes

This is my controller

controller

this is my blade

@extends('admin.master')

@section('judul')
    Edit Kategori
@endsection

@section('content')
    <form action="/kategori" method="POST">
        @csrf
        @method('PUT')
        <div >
            <div >
            @if($errors->any())
                <div >
                    <button type="button"  data-dismiss="alert" aria-hidden="true">&times;</button>
                    <h5><i ></i> Error : </h5>
                    @foreach ($errors->all() as $error)
                        {{ $error }}
                    @endforeach
                </div>
            @endif
            <div >
                <div >
                    <input type="text"  name="judul" id="isi" placeholder="Judul" autocomplete="off" required value="{{ $kategori->judul }}">
                </div>
            </div>
            <div >
                <div >
                    <textarea name="isi" id="isi" cols="30" rows="10" placeholder="Isi"  style="resize:none;">{{ $kategori->isi }}</textarea>
                </div>
            </div>
            <div >
                <button type="submit" >Edit</button>
            </div>
        </div>
    </form>
@endsection

CodePudding user response:

Edit route::get to route::put

Route::put($uri, $callback);

https://laravel.com/docs/9.x/routing

CodePudding user response:

Route Resource only handles put for update methods but not for create method so you should create new route as mentioned by @YaMus or work with post method. Reference https://laravel.com/docs/9.x/controllers#actions-handled-by-resource-controller

CodePudding user response:

change your view form action with this one

<form method="post" action={{ route('kategori.update',$id) }}>
  • Related