invoiceninja/app/Listeners/ExpenseListener.php
Holger Lösken 0fbda85a59 Code Refactoring
- Removed unused uses
- Type hinting for method parameters
- Removed commented code
- Introduced comments for classes and methods
- Short array syntax
2016-07-03 16:19:22 +00:00

37 lines
810 B
PHP

<?php namespace App\Listeners;
use App\Models\Expense;
use App\Events\InvoiceWasDeleted;
use App\Ninja\Repositories\ExpenseRepository;
/**
* Class ExpenseListener
*/
class ExpenseListener
{
// Expenses
/**
* @var ExpenseRepository
*/
protected $expenseRepo;
/**
* ExpenseListener constructor.
* @param ExpenseRepository $expenseRepo
*/
public function __construct(ExpenseRepository $expenseRepo)
{
$this->expenseRepo = $expenseRepo;
}
/**
* @param InvoiceWasDeleted $event
*/
public function deletedInvoice(InvoiceWasDeleted $event)
{
// Release any tasks associated with the deleted invoice
Expense::where('invoice_id', '=', $event->invoice->id)
->update(['invoice_id' => null]);
}
}