Y
Y
Yaroslav Alexandrov2020-07-30 11:29:54
Laravel
Yaroslav Alexandrov, 2020-07-30 11:29:54

Why is the PUT method not supported even though it is specified in the form?

I don't understand what the problem is. I'm adding an entry. I get the error The PUT method is not supported for this route. Supported methods: POST. Everywhere they write about the token and the PUT method, but this does not solve the problem for me.
In the add post form, there is a hidden token and @method('PUT') There
5f22824669e55565782234.png
are routes
Route::get('/call/create', '[email protected]')->name('create');
Route::post('/call/store', '[email protected]')->name('store');
The list of my routes looks like this
5f2282dd1f5fd128932643.png
Form Submission:

{!! Form::open(['route' => 'admin.store']) !!}
@method('PUT')
        <div class="form-group">
    {!! Form::label('title') !!}
    {!! Form::text('title', null, ['class'=>'form-control'] ) !!}
    <div>
    <div class="form-group">
    {!! Form::submit('Create', ['class'=>'btn btn-primary']) !!}
    <div>
    {!! Form::close()!!}

The controller itself
class CallController extends Controller {
    public function index()
    {
    $call = Call::all();
     return view('backend.call.index', ['call' => $call]);
    }
    public function create()
    {
    return view('backend.call.create');
    }
    public function store(Request $request)
  {
    print($request);
  }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Alexandrov, 2020-08-04
@alexyarik

Removed @method('PUT') in the add form and the entry was added.

G
Gleb Starkov, 2020-07-30
@colonel

Route::put('/call/store', '[email protected]')->name('store');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question