improved disable/delete with relationships

This commit is contained in:
denisdulici
2017-10-16 10:51:43 +03:00
parent ae52ce5a43
commit b1b36d8a64
16 changed files with 131 additions and 311 deletions

View File

@ -81,33 +81,6 @@ class Account extends Model
$this->attributes['opening_balance'] = (float) $value;
}
public function canDelete()
{
$error = false;
if ($bill_payments = $this->bill_payments()->count()) {
$error['bills'] = $bill_payments;
}
if ($payments = $this->payments()->count()) {
$error['payments'] = $payments;
}
if ($invoice_payments = $this->invoice_payments()->count()) {
$error['invoices'] = $invoice_payments;
}
if ($revenues = $this->revenues()->count()) {
$error['revenues'] = $revenues;
}
if ($error) {
return $error;
}
return true;
}
/**
* Get the current balance.
*