php - 此路由不支持 POST 方法。支持的方法 : GET, HEAD。拉维尔

标签 php laravel

我的编辑页面有问题。当我提交时出现此错误:

The POST method is not supported for this route. Supported methods: GET, HEAD.

我不知道它来自哪里,因为我对 Laravel 还很陌生。

路线(web.php):

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');
    }

enter image description here

最佳答案

我知道这不是 OP 帖子的解决方案。然而,当我搜索此错误的答案时,这篇文章是 Google 索引的第一篇文章。因此,我觉得这会对其他人有利。

出现以下错误...

The POST method is not supported for this route. Supported methods: GET, HEAD.

是没有清除路由缓存导致的

php artisan route:cache

关于php - 此路由不支持 POST 方法。支持的方法 : GET, HEAD。拉维尔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55178647/

相关文章:

PHP session 问题

PHP - 一个方法可以返回一个指针吗?

php - Eloquent - 如何在 SQL 中不出现引号并破坏它的情况下执行 "where"操作?

php - 在 Laravel/swiftmailer 中使用自定义 SMTP 服务器失败,相同的设置在 Thunderbird 中有效

Laravel 5.5无法使用belongsTo获取选定列数据

javascript - XML 到 JSON 代理服务器未获取 XML 源

php - 未定义索引 php if ($_SERVER ['REQUEST_METHOD' ] == 'POST' ){ 找不到答案?

javascript - Laravel 5 和 AngularJS 从 url 中删除 '#'

php - Bootbox.js 提交表单前确认选择

php - Laravel 和 Redis : session driver 'array'