diff --git a/app/Notifications/PaymentCreated.php b/app/Notifications/PaymentCreated.php new file mode 100644 index 000000000000..08ac7c7ef4f2 --- /dev/null +++ b/app/Notifications/PaymentCreated.php @@ -0,0 +1,76 @@ +invoice = $invoice; + $this->payment = $payment; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * @return array + */ + public function via($notifiable) + { + return ['slack']; + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toSlack($notifiable) + { + $url = 'http://www.ninja.test/subscriptions/create'; + + return (new SlackMessage) + ->from(APP_NAME) + ->image('https://app.invoiceninja.com/favicon-v2.png') + ->content(trans('texts.received_new_payment')) + ->attachment(function ($attachment) { + $invoiceName = $this->invoice->present()->titledName; + $invoiceLink = $this->invoice->present()->multiAccountLink; + $attachment->title($invoiceName, $invoiceLink) + ->fields([ + trans('texts.client') => $this->invoice->client->getDisplayName(), + trans('texts.amount') => $this->payment->present()->amount, + ]); + }); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/database/migrations/2018_03_08_150414_add_slack_notifications.php b/database/migrations/2018_03_08_150414_add_slack_notifications.php new file mode 100644 index 000000000000..81d81de7eec7 --- /dev/null +++ b/database/migrations/2018_03_08_150414_add_slack_notifications.php @@ -0,0 +1,32 @@ +string('slack_webhook_url')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function ($table) { + $table->dropColumn('slack_webhook_url'); + }); + } +}