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,25 +81,6 @@ class Item extends Model
$this->attributes['purchase_price'] = (float) $value;
}
public function canDelete()
{
$error = false;
if ($bills = $this->bill_items()->count()) {
$error['bills'] = $bills;
}
if ($invoices = $this->invoice_items()->count()) {
$error['invoices'] = $invoices;
}
if ($error) {
return $error;
}
return true;
}
public static function getItems($filter_data = array())
{
if (empty($filter_data)) {