What scenarios or requirements will be used under the Laravel Event and listener?

Source: Internet
Author: User
Look at the event and listener can not imagine the usual development process will be able to use them.
Can you tell us about their merits and usage scenarios?

Reply content:

Look at the event and listener can not imagine the usual development process will be able to use them.
Can you tell us about their merits and usage scenarios?

Listener refers to the monitoring of the model?
This is too much to use, such as statistics, how many posts are published today, how many users have been registered, what monitoring delete events to implement the global data Recycle Bin, etc...

event, it is equivalent to the controller layered. Abstract some logic code that might be reused, such as logging in and registering something. Because your login may be called in more than one method, such as registering to complete the automatic login, you can invoke the login event instead of invoking the Auth controller's login method. Because the login method of the Auth controller may have the verification code judgment and so on. But this automatic login is obviously not a need.

The simplest, the background administrator operation log, each time after the Operation event ()

In fact, this thing personal use is not much, just ordinary listening, actually with you call another method no difference

There are different types of evnet, such as model event, which can be used to monitor model changes in observer mode.

  • 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.