Events with custom module



  • Hello,

    I have my own module and I would like to catch the event PageWasUpdated

    So in my module I have in ../Provider/MyModuleServiceProvider.php

    
    ...
    use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
    ...
    
    public function boot(DispatcherContract $events)
    {
            parent::boot($events);
    
            $events->listen('PageWasUpdated', function () {
                dd('do something');
            });
    
      }
    

    And it's never fired, what am I missing ?

    Thank you for you help :)


  • Global Moderator

    @motchju

    Hey, i did instructions on how you basically handle events (based on UserProfile module, but you just replace with YourModule one).
    http://forum.asgardcms.com/topic/75/adding-additional-user-data-on-user-module/11

    Tell me if you got all in place and if still having difficulties.


  • admin

    You can also view how I did it on the User module.



  • Thank you both for your help, I will try your solution soon.

    Still not yet fully comfortable with the module system


  • Global Moderator

    @motchju

    We both posted exactly same solution :)

    Modules are cool, every module has nearly full power of Laravel application itself, also there's very little restrictions on what you can and can't do.



  • yep module are cool, plus you may reuse them very easily between different applications.

    Still didn't have a chance to test what you propose, I let you know the result soon



  • work like a charm, thank you both of you for your advice, I need also to listen on the blog (update, delete, create), I will work on a PR


Log in to reply