hasMany('App\Models\Item\Item'); } public function bills() { return $this->hasMany('App\Models\Expense\Bill'); } public function invoices() { return $this->hasMany('App\Models\Income\Invoice'); } public function canDelete() { $error = false; if ($items = $this->items()->count()) { $error['items'] = $items; } if ($bills = $this->bills()->count()) { $error['bills'] = $bills; } if ($invoices = $this->invoices()->count()) { $error['invoices'] = $invoices; } if ($error) { return $error; } return true; } }