[], 'after' => ['create'], ]; /** * Handle the OrganizationActionEvent. * * @param OrganizationActionEvent $event * @return mixed */ public function handle(OrganizationActionEvent $event) { $function = Str::camel($event->action); return $this->$function($event); } /** * Create a new $organization. * * @param OrganizationActionEvent $event * @return void */ public function create(OrganizationActionEvent $event) { $client = $event->organization->client; Notification::send($client, new OrganizationActionNotification($event)); } /** * Handle the OrganizationActionEvent as a listener. * * @param OrganizationActionEvent $event * @return mixed */ public function asListener(OrganizationActionEvent $event) { if ($this->isAllowed($event)) { return $this->handle($event); } } /** * Check if the event action is allowed. * * @param OrganizationActionEvent $event * @return bool */ private function isAllowed(OrganizationActionEvent $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; } }