Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 939 Bytes

events.md

File metadata and controls

42 lines (32 loc) · 939 Bytes

Events


To listen for an event, first you need to define a listener, then register it in EventServiceProvider:

app/Providers/EventServiceProvider.php

protected $listen = [
    'Hazzard\Comments\Events\CommentWasPosted' => [
        'App\Listeners\HandleCommentWasNotification',
    ],
];

app/Listeners/HandleCommentWasNotification.php

<?php

namespace App\Listeners;

use Hazzard\Comments\Comments\Comment;
use Hazzard\Comments\Events\CommentWasPosted;

class HandleCommentWasNotification
{
   /**
    * Handle the event.
    *
    * @param  CommentWasPosted $event
    * @return void
    */
   public function handle(CommentWasPosted $event)
   {
       // Access the comment using $event->comment...
   }
}

You can find all of events in the src/Events folder.