codebar-ag / laravel-zammad

Zammad integration with Laravel.
https://zammad.com
MIT License
8 stars 0 forks source link

Zammad Notification Channel #11

Closed StanBarrows closed 1 year ago

StanBarrows commented 2 years ago

Discussed in https://github.com/codebar-ag/laravel-zammad/discussions/7

Originally posted by **jansgescheit** April 18, 2022 Hey, it would be nice to have a Notification Channel for Zammad. e.g. ```php [...] class CustomerRequest extends Notification { use Queueable; /** * Get the notification channels. * */ public function via($notifiable) { return [ ZammadChannel::class, OtherChannel::class, ]; } /** * Get the zammad representation of the notification. */ public function toZammad($notifiable) { return (new Zammad::ticketBuilder()->title([...])... } } ``` ```php [...] class ZammadChannel { /** * Send the given notification. */ public function send($notifiable, Notification $notification) { $message = $notification->toZammad($notifiable); (new Zammad())->user()->searchOrCreateByEmail($message->customer) return (new Zammad())->ticket()->create($message->body()); } } ```