Laravel Model Events - I'm a bit confused about where they're meant to go

后端 未结 9 793
长发绾君心
长发绾君心 2020-12-07 13:15

So the way I see it is that a good Laravel application should be very model- and event-driven.

I have a Model called Article. I wish to send email alert

9条回答
  •  时光取名叫无心
    2020-12-07 13:44

    I might come after the battle, but If you do not want all the fuss of extending classes or creating traits, you might want to give a try to this file exploration solution.

    Laravel 5.X solution

    Beware the folder you choose to fetch the models should only contain models to make this solution to work

    Do not forget to add the use File

    app/Providers/AppServiceProvider.php

    Hope it helps you write the less code possible!

提交回复
热议问题