How can we optimize and improve resource routing for Laravel background operations?

Source: Internet
Author: User
Resource routing is currently in use, which is convenient for common addition, deletion, query, and modification. However, some functions are not only added, deleted, checked, and modified, but also have many small functions. The current solution is to accept a param in the corresponding method of resource routing, determine the specific operation based on this (for example, asynchronously obtaining related information... resource routing is currently in use, which is convenient for common addition, deletion, query, and modification. However, some functions are not only added, deleted, checked, and modified, but also have many small functions. The current solution is to accept a param in the corresponding method of resource routing, based on this, determine the specific operation (such as asynchronously obtaining relevant information, modifying table associations, and so on) and then execute the corresponding code.
However, this will cause the resource routing methods of the controller to be bloated and not intuitive. I wonder if there are other better solutions that can take into account the simplicity and readability of the route table and controller?

Reply content:

Resource routing is currently in use, which is convenient for common addition, deletion, query, and modification. However, some functions are not only added, deleted, checked, and modified, but also have many small functions. The current solution is to accept a param in the corresponding method of resource routing, based on this, determine the specific operation (such as asynchronously obtaining relevant information, modifying table associations, and so on) and then execute the corresponding code.
However, this will cause the resource routing methods of the controller to be bloated and not intuitive. I wonder if there are other better solutions that can take into account the simplicity and readability of the route table and controller?

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

Configure the default route according to README. md, and then you can easily useModule/controller/action. In addition, different functions are called for different types of REST-style requests:Do + + This corresponds to the function name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.