Laravel 项目通过本地化实施并且运行良好。进行自定义,因为用户可以将语言(区域设置)保存在数据库中,这就是问题所在。用户能够在数据库中保存语言。并且当用户尝试编辑语言(语言环境)时出现此问题。传递给 App\Http\Controllers\CustomizeController::edit() 的参数 1 必须是 App\Model\Customize 的一个实例,给出的字符串在 CustomizeController.php public function index(){ $data = array( 'title' =>'Customize', 'heading' =>'List', 'customize' => Customize::where(['user_id' => Auth::user()->id])->first(), ); if ($data['customize']) { return redirect()->route('customize.edit', ['locale' => app()->getLocale(), 'customize' => $data['customize']]); // Redirect to Edit Route If Language available in DB } return view('Customize.index')->with($data);}route:list 命令 O/P 如下:GET|HEAD | {locale}/customize/{customize}/edit | customize.edit | App\Http\Controllers\CustomizeController@edit | web,setlocale,auth甚至试图从刀片硬编码为:<a href="{{ url(app()->getLocale().'/customize/1/edit') }}"> <button type="button" class="btn btn-warning">Edit</button> </a>
1 回答
- 1 回答
- 0 关注
- 125 浏览
添加回答
举报
0/150
提交
取消