[英]How to remove ID in URL in Laravel return
Laravel 5.4, Everything works fine but one thing is bugging me, Laravel 5.4,一切正常,但有一件事困扰着我,
When I edit my Data and submit and use return view('role.index');
当我编辑数据并提交并使用
return view('role.index');
The URL returns this : 8000/role/1
, it returns a extra ID which is I don't know where it came from here is my code:- URL返回以下内容:
8000/role/1
,它返回一个额外的ID,我不知道它的来源是我的代码:-
public function edit(Role $role)
{
return view('role.edit')->with('details', $role);
}
public function update(Request $request, Role $role)
{
$user=auth()->user();
$role->role=$request->get('role');;
$role->updated_by=$user->id;
$role->save();
return view('role.index');
}
i understood it wrong but the reason that it happens because the route of the update is a "PUT request with the id" -> http://yourwebsite/role/1 you are returning a view inside this route you are still in the Role controller and update method. 我理解这是错误的,但之所以会发生是因为更新的路由是“带有ID的PUT请求”-> http:// yourwebsite / role / 1,您正在返回此路由内的视图,但您仍在角色中控制器和更新方法。 The solution instead of returning a view just
解决方案,而不是只返回视图
return back();
at the last of the update method 在更新方法的最后
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.