mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +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>
105 lines
2.9 KiB
PHP
105 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Mail\Signup\NewSignup;
|
|
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;
|
|
|
|
class NewAccountCreated extends Notification implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected $user;
|
|
|
|
protected $company;
|
|
|
|
public $is_system;
|
|
|
|
public function __construct($user, $company, $is_system = false)
|
|
{
|
|
$this->user = $user;
|
|
$this->company = $company;
|
|
$this->is_system = $is_system;
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
*/
|
|
public function via($notifiable)
|
|
{
|
|
return ['slack', 'mail'];
|
|
}
|
|
|
|
/**
|
|
* Get the mail representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
*/
|
|
public function toMail($notifiable)
|
|
{
|
|
$user_name = $this->user->first_name.' '.$this->user->last_name;
|
|
$email = $this->user->email;
|
|
$ip = $this->user->ip;
|
|
|
|
$data = [
|
|
'title' => ctrans('texts.new_signup'),
|
|
'message' => ctrans('texts.new_signup_text', ['user' => $user_name, 'email' => $email, 'ip' => $ip]),
|
|
'url' => config('ninja.web_url'),
|
|
'button' => ctrans('texts.account_login'),
|
|
'signature' => $this->company->settings->email_signature,
|
|
'logo' => $this->company->present()->logo(),
|
|
];
|
|
|
|
return (new MailMessage)
|
|
->subject(ctrans('texts.new_signup'))
|
|
->withSwiftMessage(function ($message) {
|
|
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
|
|
})
|
|
->markdown('email.admin.generic', $data);
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
*/
|
|
public function toArray($notifiable)
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public function toSlack($notifiable)
|
|
{
|
|
$this->user->setCompany($this->company);
|
|
|
|
$user_name = $this->user->first_name.' '.$this->user->last_name;
|
|
$email = $this->user->email;
|
|
$ip = $this->user->ip;
|
|
|
|
return (new SlackMessage)
|
|
->success()
|
|
->from(ctrans('texts.notification_bot'))
|
|
->image('https://app.invoiceninja.com/favicon.png')
|
|
->content("A new account has been created by {$user_name} - {$email} - from IP: {$ip}");
|
|
}
|
|
}
|