Add Notification class to DocumentReminded event
This commit is contained in:
parent
2d023873cc
commit
ec7511a8bc
@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
||||
use App\Events\Document\DocumentReminded;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Document\Document;
|
||||
use App\Notifications\Purchase\Bill as Notification;
|
||||
use App\Utilities\Overrider;
|
||||
use Date;
|
||||
use Illuminate\Console\Command;
|
||||
@ -84,7 +85,7 @@ class BillReminder extends Command
|
||||
|
||||
foreach ($bills as $bill) {
|
||||
try {
|
||||
event(new DocumentReminded($bill));
|
||||
event(new DocumentReminded($bill, Notification::class));
|
||||
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
|
||||
$this->error($e->getMessage());
|
||||
|
||||
|
@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
||||
use App\Events\Document\DocumentReminded;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Document\Document;
|
||||
use App\Notifications\Sale\Invoice as Notification;
|
||||
use App\Utilities\Overrider;
|
||||
use Date;
|
||||
use Illuminate\Console\Command;
|
||||
@ -84,7 +85,7 @@ class InvoiceReminder extends Command
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
try {
|
||||
event(new DocumentReminded($invoice));
|
||||
event(new DocumentReminded($invoice, Notification::class));
|
||||
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
|
||||
$this->error($e->getMessage());
|
||||
|
||||
|
@ -3,18 +3,22 @@
|
||||
namespace App\Events\Document;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
use App\Models\Document\Document;
|
||||
|
||||
class DocumentReminded extends Event
|
||||
{
|
||||
public $document;
|
||||
public $notification;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $document
|
||||
* @param $notification
|
||||
*/
|
||||
public function __construct($document)
|
||||
public function __construct(Document $document, string $notification)
|
||||
{
|
||||
$this->document = $document;
|
||||
$this->notification = $notification;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,6 @@
|
||||
namespace App\Listeners\Document;
|
||||
|
||||
use App\Events\Document\DocumentReminded as Event;
|
||||
use App\Models\Document\Document;
|
||||
use App\Notifications\Sale\Invoice as InvoiceNotification;
|
||||
use App\Notifications\Purchase\Bill as BillNotification;
|
||||
|
||||
class SendDocumentReminderNotification
|
||||
{
|
||||
@ -18,11 +15,7 @@ class SendDocumentReminderNotification
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$document = $event->document;
|
||||
|
||||
$notification = InvoiceNotification::class;
|
||||
if ($document->type === Document::BILL_TYPE) {
|
||||
$notification = BillNotification::class;
|
||||
}
|
||||
$notification = $event->notification;
|
||||
|
||||
// Notify the customer
|
||||
if ($document->contact && !empty($document->contact_email)) {
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace App\Events\Purchase;
|
||||
|
||||
use App\Events\Document\DocumentReminded;
|
||||
use App\Models\Document\Document;
|
||||
use App\Notifications\Purchase\Bill as Notification;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
@ -10,4 +12,8 @@ use App\Events\Document\DocumentReminded;
|
||||
*/
|
||||
class BillReminded extends DocumentReminded
|
||||
{
|
||||
public function __construct(Document $document)
|
||||
{
|
||||
parent::__construct($document, Notification::class);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace App\Events\Sale;
|
||||
|
||||
use App\Events\Document\DocumentReminded;
|
||||
use App\Models\Document\Document;
|
||||
use App\Notifications\Sale\Invoice as Notification;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
@ -10,4 +12,8 @@ use App\Events\Document\DocumentReminded;
|
||||
*/
|
||||
class InvoiceReminded extends DocumentReminded
|
||||
{
|
||||
public function __construct(Document $document)
|
||||
{
|
||||
parent::__construct($document, Notification::class);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user