在laravel上使用返回视图更改URL

问题描述 投票:0回答:1

我使用REST api进行CRUD。 当我在CRUD之后使用返回重定向时,Laravel不会向我发送变量 我不想使用会话。我的代码

return redirect("inventories")->with([ 'Tab' => 5,'flag' => 'success', 'flagMsg' => 'delete_successful', 'Inventories' => $Inventory]);

当我使用返回视图时,Laravel发送变量,但URL不会更改,我想重定向并更改URl,例如我的URL是/inventories/2/edit,更新后发送给/inventories/update,我想重定向inventories

php laravel redirect laravel-5 laravel-5.4
1个回答
0
投票

你也可以使用link_to_route()和link_to_action()方法。 (资源)

link_to_route采用三个参数(名称,标题和参数)。您可以像下面这样使用它:

link_to_route('api.GetAPI', 'get api', [ 
  'page_no' => $page_no,
  'id' => $id
]);

如果要使用操作,link_to_action()非常相似,但它使用操作名称而不是路由。

link_to_action('ApiController@getApi', 'get api', [ 
  'page_no' => $page_no,
  'id' => $id
]);
© www.soinside.com 2019 - 2024. All rights reserved.