我正在使用任何类型的路由,然后在此方法中,我正在处理一种请求类型的基础。laravel路由重定向问题(laravel 5.3)
路线
Route::any('/setting/custom-header/{id?}', '[email protected]');
从控制器检查类型之前,我检查它像这样
if ($id == Auth::user()->id || Auth::user()->is_admin){}
由于该请求是得到它给出了一个观点,我的网址是这样的http://app-full.dev/setting/custom-header/1
这里是通过我在我登录的用户的ID,我回国的观点如下:
return view('setting/custom-header')->with(compact('custom_headers','id'));
这是对我很好。
当请求发布后,它来的方法。创建我想返回回的数据后,如上面的URL意味着对http://app-full.dev/setting/custom-header/1 相同的用户在这里通过登录结束,我使用的意思是ID重定向为
return redirect('setting/custom-header/id');
这里/ ID其实就是用户的ID。 。我不知道我怎么能在这里给id,这样url就可以以正确的方式来代替关键字id。 谢谢如果有人能帮助解决这个问题!
得益于其在上述情况下,我是用ASLO在我的脚本索引i如何能为它做的工作? 'window.location.href =“/ setting/custom-header/id”; ' –
您可以将视图的用户标识传递给HTML/javascript。 你可以在https://laravel.com/docs/5.3/views#passing-data-to-views上阅读更多关于它的信息。要打印变量,你必须使用'window.location.href =“/ setting/custom-header/{{$ id}}”; ' –
我在这里传递id作为'返回视图('设置/自定义头') - >与(紧凑型('custom_headers','id')); '不知道如何连接,所以请 –