v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@ -1,69 +0,0 @@
<?php
namespace App\Notifications\Common;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class Item extends Notification
{
/**
* The item model.
*
* @var object
*/
public $item;
/**
* Create a notification instance.
*
* @param object $item
*/
public function __construct($item)
{
$this->item = $item;
}
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail', 'database'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$message = (new MailMessage)
->line(trans('items.notification.message.out_of_stock', ['name' => $this->item->name]))
->action(trans('items.notification.button'), url('items/items', $this->item->id));
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));
return $message;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'item_id' => $this->item->id,
'name' => $this->item->name,
];
}
}

View File

@ -1,69 +0,0 @@
<?php
namespace App\Notifications\Common;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class ItemReminder extends Notification
{
/**
* The item model.
*
* @var object
*/
public $item;
/**
* Create a notification instance.
*
* @param object $item
*/
public function __construct($item)
{
$this->item = $item;
}
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail', 'database'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$message = (new MailMessage)
->line(trans('items.notification.message.reminder', ['name' => $this->item->name, 'quantity' => $this->item->quantity]))
->action(trans('items.notification.button'), url('items/items', $this->item->id));
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));
return $message;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'item_id' => $this->item->id,
'name' => $this->item->name,
];
}
}

View File

@ -1,83 +0,0 @@
<?php
namespace App\Notifications\Customer;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class Invoice extends Notification
{
/**
* The bill model.
*
* @var object
*/
public $invoice;
public $invoice_payment;
/**
* Create a notification instance.
*
* @param object $invoice
*/
public function __construct($invoice, $invoice_payment)
{
$this->queue = 'high';
$this->delay = config('queue.connections.database.delay');
$this->invoice = $invoice;
$this->invoice_payment = $invoice_payment;
}
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail', 'database'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$message = (new MailMessage)
->line(trans('customers.notification.message', ['invoice_number' => $this->invoice->invoice_number, 'amount' => money($this->invoice_payment->amount, $this->invoice_payment->currency_code, true), 'customer' => $this->invoice->customer_name]));
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));
// Attach the PDF file if available
if (isset($this->invoice->pdf_path)) {
$message->attach($this->invoice->pdf_path, [
'mime' => 'application/pdf',
]);
}
$message->action(trans('customers.notification.button'), url('incomes/invoices', $this->invoice->id));
return $message;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'invoice_id' => $this->invoice->id,
'amount' => $this->invoice->amount,
];
}
}

View File

@ -2,40 +2,37 @@
namespace App\Notifications\Expense;
use Illuminate\Notifications\Notification;
use App\Abstracts\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class Bill extends Notification
{
/**
* The invoice model.
* The bill model.
*
* @var object
*/
public $bill;
/**
* The email template.
*
* @var string
*/
public $template;
/**
* Create a notification instance.
*
* @param object $bill
* @param object $template
*/
public function __construct($bill)
public function __construct($bill = null, $template = null)
{
$this->queue = 'high';
$this->delay = config('queue.connections.database.delay');
parent::__construct();
$this->bill = $bill;
}
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail', 'database'];
$this->template = $template;
}
/**
@ -46,12 +43,7 @@ class Bill extends Notification
*/
public function toMail($notifiable)
{
$message = (new MailMessage)
->line('You are receiving this email because you have an upcoming ' . money($this->bill->amount, $this->bill->currency_code, true) . ' bill to ' . $this->bill->vendor_name . ' vendor.')
->action('Add Payment', url('expenses/bills', $this->bill->id));
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));
$message = $this->initMessage();
return $message;
}
@ -69,4 +61,28 @@ class Bill extends Notification
'amount' => $this->bill->amount,
];
}
public function getTags()
{
return [
'{bill_number}',
'{bill_total}',
'{bill_due_date}',
'{bill_admin_link}',
'{vendor_name}',
'{company_name}',
];
}
public function getTagsReplacement()
{
return [
$this->bill->bill_number,
money($this->bill->amount, $this->bill->currency_code, true),
$this->bill->due_at,
route('bills.show', $this->bill->id),
$this->bill->contact_name,
$this->bill->company->name
];
}
}

View File

@ -2,55 +2,49 @@
namespace App\Notifications\Income;
use Illuminate\Notifications\Notification;
use App\Abstracts\Notification;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\URL;
class Invoice extends Notification
{
/**
* The bill model.
* The invoice model.
*
* @var object
*/
public $invoice;
/**
* The email template.
*
* @var string
*/
public $template;
/**
* Create a notification instance.
*
* @param object $invoice
* @param object $template
*/
public function __construct($invoice)
public function __construct($invoice = null, $template = null)
{
$this->queue = 'high';
$this->delay = config('queue.connections.database.delay');
parent::__construct();
$this->invoice = $invoice;
$this->template = $template;
}
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail', 'database'];
}
/**
* Build the mail representation of the notification.
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$message = (new MailMessage)
->line(trans('invoices.notification.message', ['amount' => money($this->invoice->amount, $this->invoice->currency_code, true), 'customer' => $this->invoice->customer_name]));
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));
$message = $this->initMessage();
// Attach the PDF file if available
if (isset($this->invoice->pdf_path)) {
@ -59,10 +53,6 @@ class Invoice extends Notification
]);
}
if ($this->invoice->customer->user) {
$message->action(trans('invoices.notification.button'), url('customers/invoices', $this->invoice->id));
}
return $message;
}
@ -79,4 +69,32 @@ class Invoice extends Notification
'amount' => $this->invoice->amount,
];
}
public function getTags()
{
return [
'{invoice_number}',
'{invoice_total}',
'{invoice_due_date}',
'{invoice_guest_link}',
'{invoice_admin_link}',
'{invoice_portal_link}',
'{customer_name}',
'{company_name}',
];
}
public function getTagsReplacement()
{
return [
$this->invoice->invoice_number,
money($this->invoice->amount, $this->invoice->currency_code, true),
$this->invoice->due_at,
URL::signedRoute('signed.invoices.show', [$this->invoice->id, 'company_id' => $this->invoice->company_id]),
route('invoices.show', $this->invoice->id),
route('portal.invoices.show', $this->invoice->id),
$this->invoice->contact_name,
$this->invoice->company->name
];
}
}

View File

@ -0,0 +1,115 @@
<?php
namespace App\Notifications\Portal;
use App\Abstracts\Notification;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\URL;
class PaymentReceived extends Notification
{
/**
* The bill model.
*
* @var object
*/
public $invoice;
/**
* The payment transaction.
*
* @var string
*/
public $transaction;
/**
* The email template.
*
* @var string
*/
public $template;
/**
* Create a notification instance.
*
* @param object $invoice
*/
public function __construct($invoice = null, $transaction = null, $template = null)
{
parent::__construct();
$this->invoice = $invoice;
$this->transaction = $transaction;
$this->template = $template;
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$message = $this->initMessage();
// Attach the PDF file if available
if (isset($this->invoice->pdf_path)) {
$message->attach($this->invoice->pdf_path, [
'mime' => 'application/pdf',
]);
}
return $message;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'invoice_id' => $this->invoice->id,
'amount' => $this->invoice->amount,
];
}
public function getTags()
{
return [
'{invoice_number}',
'{invoice_total}',
'{invoice_due_date}',
'{invoice_status}',
'{invoice_guest_link}',
'{invoice_admin_link}',
'{invoice_portal_link}',
'{transaction_total}',
'{transaction_paid_date}',
'{transaction_payment_method}',
'{customer_name}',
'{company_name}',
];
}
public function getTagsReplacement()
{
return [
$this->invoice->invoice_number,
money($this->invoice->amount, $this->invoice->currency_code, true),
$this->invoice->due_at,
trans('invoices.status.' . $this->invoice->invoice_status_code),
URL::signedRoute('signed.invoices.show', [$this->invoice->id, 'company_id' => $this->invoice->company_id]),
route('invoices.show', $this->invoice->id),
route('portal.invoices.show', $this->invoice->id),
money($this->transaction->amount, $this->transaction->currency_code, true),
$this->transaction->paid_at,
$this->transaction->payment_method,
$this->invoice->contact_name,
$this->invoice->company->name
];
}
}