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

@ -59,23 +59,4 @@ class Customer extends Model
{
return $this->belongsTo('App\Models\Auth\User', 'customer_id', 'id');
}
public function canDelete()
{
$error = false;
if ($invoices = $this->invoices()->count()) {
$error['invoices'] = $invoices;
}
if ($revenues = $this->revenues()->count()) {
$error['revenues'] = $revenues;
}
if ($error) {
return $error;
}
return true;
}
}