php - 路线 [companies.show] 未定义
问题描述
我收到此错误(Route [companies.show] 未定义。)我不知道该怎么做。实际上我正在更新 CompaniesController 中的数据并且数据正在更新但路由不起作用这是代码:
public function update(Request $request, Company $company){
$companyUpdate = Company::where('id', $company->id)->update(['name'=> $request->input('name'),'description'=> $request->input('description')]);
if($companyUpdate){
return redirect()->route('companies.show', ['company'=> $company->id])
->with('success' , 'Company updated successfully');
}
return back()->withInput();
我的 web.php 文件如下`
Route::get('/', function () {
return view('welcome');});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::resource('/company','CompaniesController');
提前感谢您帮助我
解决方案
将公司更改为
return redirect()->route('company.show', ['company'=> $company->id])
->with('success' , 'Company updated successfully');
}
推荐阅读
- python-requests - 在 Python 请求库的 Header 中使用 JSON
- c# - Xamarin.Forms iOS 在带有自定义控件的 XAML 页面上崩溃
- cx-freeze - 用 cx_freeze 构建 python 是不可能的
- bash - 在同一行上的特定单词之后读取单词,它们之间没有空格
- python - 如何使用 pandas 从 .xls 文件中读取合并的单元格
- python - ski-kitlearn 中岭回归分类器的在线版本?
- rx-swift - 在 RxSwift 中设置 TextField 字符的限制
- aws-sdk - 如何使用 AWSSDK.S3 上传单个块负载?
- asp.net-core - ASP.NET Core - 生成的 web.config 中的 processPath 错误
- powermockito - 使用 MockitToRunner 运行的 powermock - 获取匹配器错误