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