Fix condition

This commit is contained in:
harshjagad20
2022-03-03 15:10:53 +05:30
parent 388d00241b
commit 25c43ab4d2
5 changed files with 24 additions and 65 deletions

View File

@ -380,4 +380,21 @@ class Company extends Model implements HasMedia
$model->taxes()->delete();
}
}
public function hasTransactions()
{
if (
$this->customers()->exists() ||
$this->items()->exists() ||
$this->invoices()->exists() ||
$this->estimates()->exists() ||
$this->expenses()->exists() ||
$this->payments()->exists() ||
$this->recurringInvoices()->exists()
) {
return true;
}
return false;
}
}

View File

@ -12,56 +12,4 @@ class Currency extends Model
protected $guarded = [
'id'
];
public function customers()
{
return $this->hasMany(Customer::class);
}
public function items()
{
return $this->hasMany(Item::class);
}
public function invoices()
{
return $this->hasMany(Invoice::class);
}
public function estimates()
{
return $this->hasMany(Estimate::class);
}
public function expenses()
{
return $this->hasMany(Expense::class);
}
public function payments()
{
return $this->hasMany(Payment::class);
}
public function recurringInvoices()
{
return $this->hasMany(RecurringInvoice::class);
}
public function checkTransactions()
{
if (
$this->customers()->exists() ||
$this->items()->exists() ||
$this->invoices()->exists() ||
$this->estimates()->exists() ||
$this->expenses()->exists() ||
$this->payments()->exists() ||
$this->recurringInvoices()->exists()
) {
return true;
}
return false;
}
}

View File

@ -307,7 +307,7 @@ class RecurringInvoice extends Model
$days = CompanySetting::getSetting('invoice_due_date_days', $this->company_id);
if ($days == "null") {
if (! $days || $days == "null") {
$days = 7;
}