canDelete

This commit is contained in:
denisdulici 2017-09-26 01:05:21 +03:00
parent e18dd406b2
commit 5c106c4fef
6 changed files with 32 additions and 48 deletions

View File

@ -74,24 +74,20 @@ class Account extends Model
{
$error = false;
$bill_payments = $this->bill_payments();
if ($bill_payments->count()) {
$error['bills'] = $bill_payments->count();
if ($bill_payments = $this->bill_payments()->count()) {
$error['bills'] = $bill_payments;
}
$payments = $this->payments();
if ($payments->count()) {
$error['payments'] = $payments->count();
if ($payments = $this->payments()->count()) {
$error['payments'] = $payments;
}
$invoice_payments = $this->invoice_payments();
if ($invoice_payments->count()) {
$error['invoices'] = $invoice_payments->count();
if ($invoice_payments = $this->invoice_payments()->count()) {
$error['invoices'] = $invoice_payments;
}
$revenues = $this->revenues();
if ($revenues->count()) {
$error['revenues'] = $revenues->count();
if ($revenues = $this->revenues()->count()) {
$error['revenues'] = $revenues;
}
if ($error) {

View File

@ -57,14 +57,12 @@ class Vendor extends Model
{
$error = false;
$bills = $this->bills();
if ($bills->count()) {
$error['bills'] = $bills->count();
if ($bills = $this->bills()->count()) {
$error['bills'] = $bills;
}
$payments = $this->payments();
if ($payments->count()) {
$error['payments'] = $payments->count();
if ($payments = $this->payments()->count()) {
$error['payments'] = $payments;
}
if ($error) {

View File

@ -64,14 +64,12 @@ class Customer extends Model
{
$error = false;
$invoices = $this->invoices();
if ($invoices->count()) {
$error['invoices'] = $invoices->count();
if ($invoices = $this->invoices()->count()) {
$error['invoices'] = $invoices;
}
$revenues = $this->revenues();
if ($revenues->count()) {
$error['revenues'] = $revenues->count();
if ($revenues = $this->revenues()->count()) {
$error['revenues'] = $revenues;
}
if ($error) {

View File

@ -85,14 +85,12 @@ class Item extends Model
{
$error = false;
$bills = $this->bills();
if ($bills->count()) {
$error['bills'] = $bills->count();
if ($bills = $this->bills()->count()) {
$error['bills'] = $bills;
}
$invoices = $this->invoices();
if ($invoices->count()) {
$error['invoices'] = $invoices->count();
if ($invoices = $this->invoices()->count()) {
$error['invoices'] = $invoices;
}
if ($error) {

View File

@ -44,19 +44,16 @@ class Category extends Model
{
$error = false;
$items = $this->items();
if ($items->count()) {
$error['items'] = $items->count();
if ($items = $this->items()->count()) {
$error['items'] = $items;
}
$payments = $this->payments();
if ($payments->count()) {
$error['payments'] = $payments->count();
if ($payments = $this->payments()->count()) {
$error['payments'] = $payments;
}
$revenues = $this->revenues();
if ($revenues->count()) {
$error['revenues'] = $revenues->count();
if ($revenues = $this->revenues()->count()) {
$error['revenues'] = $revenues;
}
if ($error) {

View File

@ -45,19 +45,16 @@ class Tax extends Model
{
$error = false;
$items = $this->items();
if ($items->count()) {
$error['items'] = $items->count();
if ($items = $this->items()->count()) {
$error['items'] = $items;
}
$bills = $this->bills();
if ($bills->count()) {
$error['bills'] = $bills->count();
if ($bills = $this->bills()->count()) {
$error['bills'] = $bills;
}
$invoices = $this->invoices();
if ($invoices->count()) {
$error['invoices'] = $invoices->count();
if ($invoices = $this->invoices()->count()) {
$error['invoices'] = $invoices;
}
if ($error) {