Events


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

Example

app/Providers/EventServiceProvider.php

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

app/Listeners/SendEmailNotification.php

<?php

namespace App\Listeners;

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

class SendEmailNotification
{
    /**
    * Create the event listener.
    *
    * @return void
    */
   public function __construct()
   {
       //
   }

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

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