[], 'after' => ['create'], ]; /** * Handle the CertificateActionEvent. * * @param CertificateActionEvent $event * @return mixed */ public function handle(CertificateActionEvent $event) { $function = Str::camel($event->action); return $this->$function($event); } /** * Create a new $certificate. * * @param CertificateActionEvent $event * @return void */ public function create(CertificateActionEvent $event) { $client = $event->certificate->client; Notification::send($client, new CertificateActionNotification($event)); } /** * Handle the CertificateActionEvent as a listener. * * @param CertificateActionEvent $event * @return mixed */ public function asListener(CertificateActionEvent $event) { if ($this->isAllowed($event)) { return $this->handle($event); } } /** * Check if the event action is allowed. * * @param CertificateActionEvent $event * @return bool */ private function isAllowed(CertificateActionEvent $event) { if ($event->when == 'before' && !in_array($event->action, $this->allowedActions['before'])) { return false; } if (($event->when == 'after' && !in_array($event->action, $this->allowedActions['after'])) ) { return false; } return true; } }