Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-01 07:12:28 11月16日 Update

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!

Tags: Parameters routing articles resources questions values interests and at the same time that is situation meaning method time more friends knowledge editing industry details information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi Docker Apple NVidia