Fix – the get method is not supported for this route. supported methods

If you are getting the get method is not supported for this route. supported methods error, this article will help you fix the issue. consider…

The post Fix – the get method is not supported for this route. supported methods appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Deven

If you are getting the get method is not supported for this route. supported methods error, this article will help you fix the issue.

consider the following code example which can throw you same error.

Route::group(['middleware'` => 'auth'], function () {
Route::get('/', 'ProjectController@index');

Route::get('/projects/{id}', 'ProjectController@show');
Route::post('/create','ProjectController@store');
Route::get('/create', 'ProjectController@create');
Route::get('/projects/{id}/delete', 'ProjectController@destroy');
Route::put('/edit','ProjectController@update');
Route::get('/projects/{id}/edit', 'ProjectController@edit');

}); 

Controller:
public function edit($id)
    {
        return view('project.edit',[

            'project' => Project::find($id)
        ]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request)
    {
        $project = Project::find($request->id);
        $project->project_name = $request->input('project_name');
        $project->client = $request->input('client');
        $project->description = $request->input('description');
        $project->time_span = $request->input('time_span');
        $project->text_report = $request->input('text_report');
        $project->created_by = $request->input('created_by');

        $project->save();

        return  redirect('/')->with('success', 'Project aangepast');
    }`

In the example code snippet above if you insist on using PUTyou can change the form action to POST and add a hidden method_fieldthat has a value PUTand a hidden csrf field (if you are using blade then you just need to add @csrf_field and {{ method_field('PUT') }}). This way the form would accept the request. You can also simply change the route and form method to POST. It will work just fine since you are the one defining the route and not using the resource group.

The post Fix – the get method is not supported for this route. supported methods appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Deven


Print Share Comment Cite Upload Translate Updates
APA

Deven | Sciencx (2021-02-26T14:34:04+00:00) Fix – the get method is not supported for this route. supported methods. Retrieved from https://www.scien.cx/2021/02/26/fix-the-get-method-is-not-supported-for-this-route-supported-methods/

MLA
" » Fix – the get method is not supported for this route. supported methods." Deven | Sciencx - Friday February 26, 2021, https://www.scien.cx/2021/02/26/fix-the-get-method-is-not-supported-for-this-route-supported-methods/
HARVARD
Deven | Sciencx Friday February 26, 2021 » Fix – the get method is not supported for this route. supported methods., viewed ,<https://www.scien.cx/2021/02/26/fix-the-get-method-is-not-supported-for-this-route-supported-methods/>
VANCOUVER
Deven | Sciencx - » Fix – the get method is not supported for this route. supported methods. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/26/fix-the-get-method-is-not-supported-for-this-route-supported-methods/
CHICAGO
" » Fix – the get method is not supported for this route. supported methods." Deven | Sciencx - Accessed . https://www.scien.cx/2021/02/26/fix-the-get-method-is-not-supported-for-this-route-supported-methods/
IEEE
" » Fix – the get method is not supported for this route. supported methods." Deven | Sciencx [Online]. Available: https://www.scien.cx/2021/02/26/fix-the-get-method-is-not-supported-for-this-route-supported-methods/. [Accessed: ]
rf:citation
» Fix – the get method is not supported for this route. supported methods | Deven | Sciencx | https://www.scien.cx/2021/02/26/fix-the-get-method-is-not-supported-for-this-route-supported-methods/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.