invoiceninja/app/Listeners/ExpenseListener.php
2016-05-01 14:31:10 +03:00

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]);
}
}