Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of carrying parameters in resource routing in laravel-admin

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to solve the problem of resource routing carrying parameters in laravel-admin, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.

To define a resource route in laravel-admin, there are parameters, such as

$router- > resource ('{type} / articles', ArticleController::class)

There is no problem on the list page, but when it comes to the editing and details page, since the parameter matching for the route is done from left to right, which means that when the first parameter is detected, it will be considered to be $id, in which case we need to override the edit,show,update method. As follows

/ Note that the article in the parameter below is related to your routing parameters. For example, I am articles. By default, this parameter is articlepublic function edit ($id, Content $content) {$id = request ()-> route ()-> parameter ("article"); return parent::edit ($id, $content); / / TODO: Change the autogenerated stub} public function update ($id) {$id = request ()-> route ()-> parameter ("article"); return $this- > form ()-> update ($id) } Thank you for reading this article carefully. I hope the article "how to solve the problem of Resource routing parameters in laravel-admin" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report