*/ private Collection $messages; public function __construct() { $this->messages = new Collection(); $this->enable = config('slack.enable', false); } public function send($message = null) { if ($this->enable) { $this->messages->push(new SlackNotification($message)); } } public function hasMessage(): bool { return $this->messages->isNotEmpty(); } public function commit() { if (!$this->hasMessage()) return; foreach ($this->messages as $message) { $this->notify($message); logger('Slack通知登録'); } $this->messages->empty(); } public function routeNotificationForSlack() { return config('slack.channel'); } }