How to better optimize and improve resource routing for Laravel background operations?

WBOY
Release: 2016-09-19 09:16:36
Original
986 people have browsed it

I am currently using resource routing, which is indeed very convenient for ordinary additions, deletions, checks and modifications. But some functions are not only adding, deleting, checking and modifying, but also have many small functions. The current solution is to accept a param in the method corresponding to the resource routing, and use this to determine the specific operation (such as asynchronously obtaining relevant information, modifying table associations) class, etc.) and then execute the corresponding code.
But this will cause the resource routing methods of the controller to be bloated and not intuitive. I wonder if there are any other better solutions that can keep the routing table and the controller relatively simple and readable?

Reply content:

I am currently using resource routing, which is indeed very convenient for ordinary additions, deletions, checks and modifications. But some functions are not only adding, deleting, checking and modifying, but also have many small functions. The current solution is to accept a param in the method corresponding to the resource routing, and use this to determine the specific operation (such as asynchronously obtaining relevant information, modifying table associations) class, etc.) and then execute the corresponding code.
But this will cause the resource routing methods of the controller to be bloated and not intuitive. I wonder if there are any other better solutions that can keep the routing table and the controller relatively simple and readable?

You may need something like this: laravel-default-routes

Configure this default route according to README.md, and then you can easily use the module/controller/action route in other frameworks. And different functions are called for different types of REST-style requests: do + <HTTP_METHOD> + <action>This corresponds to the function name.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template