mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:57:33 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			625 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			625 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php namespace app\Listeners;
 | 
						|
 | 
						|
use Carbon;
 | 
						|
use App\Models\Expense;
 | 
						|
use App\Events\PaymentWasDeleted;
 | 
						|
use App\Events\InvoiceWasDeleted;
 | 
						|
use App\Ninja\Repositories\ExpenseRepository;
 | 
						|
 | 
						|
class ExpenseListener
 | 
						|
{
 | 
						|
    // Expenses
 | 
						|
    protected $expenseRepo;
 | 
						|
 | 
						|
    public function __construct(ExpenseRepository $expenseRepo)
 | 
						|
    {
 | 
						|
        $this->expenseRepo = $expenseRepo;
 | 
						|
    }
 | 
						|
 | 
						|
    public function deletedInvoice(InvoiceWasDeleted $event)
 | 
						|
    {
 | 
						|
        // Release any tasks associated with the deleted invoice
 | 
						|
        Expense::where('invoice_id', '=', $event->invoice->id)
 | 
						|
                ->update(['invoice_id' => null]);
 | 
						|
    }
 | 
						|
}
 |