mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 06:32:40 +01:00
ba75a44eb8
* Adopt Laravel coding style The Laravel framework adopts the PSR-2 coding style with some additions. Laravel apps *should* adopt this coding style as well. However, Shift allows you to customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config to your project. You may use [Shift's .php_cs][2] file as a base. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 * Shift bindings PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser. * Shift core files * Shift to Throwable * Add laravel/ui dependency * Unindent vendor mail templates * Shift config files * Default config files In an effort to make upgrading the constantly changing config files easier, Shift defaulted them so you can review the commit diff for changes. Moving forward, you should use ENV variables or create a separate config file to allow the core config files to remain automatically upgradeable. * Shift Laravel dependencies * Shift cleanup * Upgrade to Laravel 7 Co-authored-by: Laravel Shift <shift@laravelshift.com>
114 lines
3.3 KiB
PHP
114 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Mail\RecurringCancellationRequest;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Messages\SlackMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
class ClientContactRequestCancellation extends Notification implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected $recurring_invoice;
|
|
|
|
protected $client_contact;
|
|
|
|
/**
|
|
* The callback that should be used to build the mail message.
|
|
*
|
|
* @var \Closure|null
|
|
*/
|
|
public static $toMailCallback;
|
|
|
|
public function __construct($recurring_invoice, $client_contact)
|
|
{
|
|
$this->recurring_invoice = $recurring_invoice;
|
|
$this->client_contact = $client_contact;
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
*/
|
|
public function via($notifiable)
|
|
{
|
|
return ['mail', 'slack'];
|
|
}
|
|
|
|
/**
|
|
* Get the mail representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
*/
|
|
public function toMail($notifiable)
|
|
{
|
|
if (static::$toMailCallback) {
|
|
return call_user_func(static::$toMailCallback, $notifiable, $this->client_contact);
|
|
}
|
|
|
|
$client_contact_name = $this->client_contact->present()->name();
|
|
$client_name = $this->client_contact->client->present()->name();
|
|
$recurring_invoice_number = $this->recurring_invoice->number;
|
|
|
|
return (new MailMessage)
|
|
->subject('Request for recurring invoice cancellation from '.$client_contact_name)
|
|
->markdown('email.support.cancellation', [
|
|
'message' => "Contact [{$client_contact_name}] from Client [{$client_name}] requested to cancel Recurring Invoice [#{$recurring_invoice_number}]",
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
*/
|
|
public function toArray($notifiable)
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public function toSlack($notifiable)
|
|
{
|
|
$name = $this->client_contact->present()->name();
|
|
$client_name = $this->client_contact->client->present()->name();
|
|
$recurring_invoice_number = $this->recurring_invoice->number;
|
|
|
|
return (new SlackMessage)
|
|
->success()
|
|
->to('#devv2')
|
|
->from('System')
|
|
->image('https://app.invoiceninja.com/favicon.png')
|
|
->content("Contact {$name} from client {$client_name} requested to cancel Recurring Invoice #{$recurring_invoice_number}");
|
|
}
|
|
|
|
/**
|
|
* Set a callback that should be used when building the notification mail message.
|
|
*
|
|
* @param \Closure $callback
|
|
* @return void
|
|
*/
|
|
public static function toMailUsing($callback)
|
|
{
|
|
static::$toMailCallback = $callback;
|
|
}
|
|
}
|