【问题标题】:Laravel Route not defined error on FP_routeFP_route 上的 Laravel Route 未定义错误
【发布时间】:2021-03-08 19:16:44
【问题描述】:

我在使用 POST 时遇到问题,当我尝试运行页面并将数据加载到我尝试读取的数据库表中时,我总是收到 Route [MAILFP_Tree] not defined 错误。

代码是通过调用刀片文件中的路由来触发的,该路由将可视化页面

<form action="{{route('MAILFP_Tree')}}" method="post">

路线如下

Route::get('FP_Tree', 'HomeController@toFP_Tree')->middleware('auth');
Route::post('FP_Tree', 'MailController@toFP_Tree')->middleware('auth')->name('MAILFP_Tree');

这是为 post 方法创建的控制器(称为 mailController)

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use \Illuminate\Support\Facades\Mail;
use App\Mail\emailFP_TreeRow;
use DB;
use Auth;
use App\AssociationHistorical;

class MailController extends Controller
{
    public function toFP_Tree(Request $request)
    {
        $order_number = $request->input('order_number');
        $customer_name = $request->input('customer_name');
        $date_order_placed = $request->input('date_order_placed');
        $item_number = $request->input('item_number');
        $quantity = $request->input('quantity');
        $item_description = $request->input('item_description');

        $passed = array($order_number, $customer_name, $date_order_placed, $item_number, $quantity, $item_description);

        Mail::to(Auth::user()->email)->send(new emailFP_TreeRow($passed));

        //passes data to blade
        $rows = AssociationHistorical::all();
        return view('FP_Tree',[
            'rows'=>$rows
        ]);

    }
}

这是家庭控制器的内容

 public function toFP_Tree()
    {
        //passes data to blade
        $rows = AssociationHistorical::all();
        return view('FP_Tree',[
            'rows'=>$rows
        ]);
    }

这是我的迁移表

    Schema::create('association_historical', function (Blueprint $table) {
        $table->id();
        $table->string('order_number');
        $table->string('item_number');
        $table->string('item_description');
        $table->date('date_order_placed');
        $table->string('customer_name')->nullable();
        $table->string('sales_rep_email');

    });

问题是association_historical表中有数据时会出现问题,很可能与数据库中没有数据时不会运行post方法的事实有关,但我认为它显示数据库表是有意义的...

奇怪的是,在别人的电脑上这工作没有任何问题。

这是 PHP artisan route:list 的结果

+--------+----------+--------+-- ---------------------+---------------------------- ---------------------------------+------------+ |域名 |方法 |网址 |姓名 |行动 |中间件 | +--------+----------+--------+-------- ---------------------+---------------------------- ------------------+------------+ | |得到|头| / |生成::UYk0LlF0PlICNJsK |应用\Http\Controllers\LoginPageController@showLogin |网络 |

| |发布 | / |登录 |应用\Http\Controllers\LoginPageController@doLogin |网络 |

| |得到|头| FP_树 |生成::98bieUMU1hfvx1TH | App\Http\Controllers\HomeController@toFP_Tree |网络 |

| | | | | |认证 | | |得到|头|预测 |生成::4HdessOBvQL3KmpT | App\Http\Controllers\HomeController@toPrediction |网络 |

| | | | | |认证 |

| |得到|头|预测着陆 |生成::Xtf7I1MCKtlOSX3Y | App\Http\Controllers\HomeController@toPredictionsLanding |网络 |

| | | | | |认证 |

| |得到|头|用户管理 |生成::aOYFVG9JOLTfGjB5 | App\Http\Controllers\HomeController@toUserManagement |网络 |

| | | | | |认证 |

| |得到|头| api/用户 |生成::3SA9mFdg4RMncH1a |关闭 |接口 |

| | | | | |身份验证:api | | |得到|头|登出 |生成::YeCPB1fIxlH8JqDe | App\Http\Controllers\HomeController@doLogout |网络 |

| | | | | |认证 | +--------+----------+--------+-------- ---------------------+---------------------------- ------------------+------------+

【问题讨论】:

  • 你可能缓存了路由,试试php artisan route:clear
  • 我觉得自己像个白痴。它确实修复了它。非常非常感谢!

标签: laravel post routes laravel-8


【解决方案1】:

非常简单,感谢 DigitalDrifter,只需要做一个 php artisan route:clear

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-06
    • 2022-07-13
    • 1970-01-01
    • 2018-11-08
    • 2019-12-31
    • 2017-09-05
    • 2018-08-23
    • 2021-11-30
    相关资源
    最近更新 更多