php - 试图获取非对象 laravel7.7 的属性“id”
问题描述
大家好,我在路由中使用前缀进行本地化,当我制作 dd($id); 时,显示和编辑方法的 id 有问题;或 echo 我发现它是前缀“en”或“fr”有人可以帮我吗
这是路线
Route::group(['prefix'=>'{language?}'], function(){
Route::get('/', function () { return view('welcome');});
Route::resource('application', 'ApplicationController');
Route::resource('appkey', 'AppKeyController');
Route::get('/export', 'ApplicationController@export')->name('export');
Route::get('/exportkey', 'AppKeyController@export')->name('exportkey');
});
Route::get('/{any}', function() {
$locale = app()->getLocale();
if( !$locale ) {
$locale = config('app.fallback_locale');
}
dd( '/' . $locale . request()->path() );
return redirect( '/' . $locale . request()->path() );
})->where('any', '.*');
public function show($id)
{
$key = AppKey::find($id);
return view('pages.keys.show') -> with('key', $key);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$app = Application::pluck('name', 'app_id');
$key = AppKey::find($id);
dd($id);
return view('pages.keys.edit', compact('app')) -> with('key', $key);
}
解决方案
推荐阅读
- javascript - 为什么加载 css 资源阻止异步脚本
- java - 使用 MPAndroidChart 库重叠的饼图标签
- kubernetes - 使用 DEX 在 Kubernetes 中进行身份验证
- visual-studio-code - 当我点击“我不信任作者”时,为什么我的文件夹处于“受限模式”?
- node.js - discord.js:如何使用 slash 命令编辑发送的消息,就像使用标准 /me 命令完成的那样
- android - 如何强制 Android Studio 使用 IDE 方案作为默认编码风格?
- mysql - 我在查询 PHP MySQL 组中有两个错误
- c# - 用于 Redis 上的 Fire and Forget 命令的基于间隔的批处理器
- powershell - Powershell:确定当前使用的物理网络适配器允许互联网连接
- mongodb - Mongodb查询实际时间使用与解释结果不同