invoice and bill reminding is moved console command to listeners
This commit is contained in:
		
							
								
								
									
										34
									
								
								app/Listeners/Sale/SendInvoiceRemindingNotification.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								app/Listeners/Sale/SendInvoiceRemindingNotification.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Listeners\Sale;
 | 
			
		||||
 | 
			
		||||
use App\Events\Sale\InvoiceReminding as Event;
 | 
			
		||||
use App\Notifications\Sale\Invoice as Notification;
 | 
			
		||||
 | 
			
		||||
class SendInvoiceRemindingNotification
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Handle the event.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  $event
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function handle(Event $event)
 | 
			
		||||
    {
 | 
			
		||||
        $invoice = $event->invoice;
 | 
			
		||||
 | 
			
		||||
        // Notify the customer
 | 
			
		||||
        if ($invoice->contact && !empty($invoice->contact_email)) {
 | 
			
		||||
            $invoice->contact->notify(new Notification($invoice, 'invoice_remind_customer'));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Notify all users assigned to this company
 | 
			
		||||
        foreach ($invoice->company->users as $user) {
 | 
			
		||||
            if (!$user->can('read-notifications')) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $user->notify(new Notification($invoice, 'invoice_remind_admin'));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user