Laravel项目未定义路线

mzaanser  于 2023-03-13  发布在  其他
关注(0)|答案(3)|浏览(109)

我正在特灵访问刀片模板上的路由,因此收到以下错误:

Route \[{$name}\] not defined.
Route::patch('/update_merchant/{merchant_id}', 'MerchantsController@update')->name('update');
刀片模板
<form name="merchants_data" id="merchants_data" method="post" action="{{route('update_merchant.update', [$item->merchant_id])}}">      
    {{ csrf_field() }}    
    {!! method_field('patch') !!}
控制器
public function update(Request $request, $merchant_id)
{
    // Validation for required fields (and using some regex to validate our numeric value)
    $request->validate([
        'fees'=>'required',
    ]); 
    $merchants = Merchants_data::findorfail($merchant_id);
    // Getting values from the blade template form
    $merchants->fees = $request->get('fees');
    $merchants->save();

    return redirect('/manage_merchants')->with('success', 'Transaction Fee updated.'); 
}
mspsb9vt

mspsb9vt1#

看起来你的路由名称是“更新”,但你调用“更新_商家.更新”

pxyaymoc

pxyaymoc2#

正如Mehran所说,您将路线命名为“update”,并在表单中调用了“update_merchant.update”。

...->name('foo');

这是您必须在

{{ route('foo') }}

你不把URL放在“路由”资产中,只把名称放在其中。

yvt65v4c

yvt65v4c3#

您似乎已更改要更新的路由的名称...
你可以做的一件事是在你的命令行中转到项目的根目录..并查找

php artisan route:list

这将为您提供应用程序中当前拥有的所有路由的列表...

相关问题