belongsTo('App\Models\ExpenseCategory')->withTrashed(); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function account() { return $this->belongsTo('App\Models\Account'); } /** * @return mixed */ public function user() { return $this->belongsTo('App\Models\User')->withTrashed(); } /** * @return mixed */ public function vendor() { return $this->belongsTo('App\Models\Vendor')->withTrashed(); } /** * @return mixed */ public function client() { return $this->belongsTo('App\Models\Client')->withTrashed(); } /** * @return mixed */ public function getName() { if ($this->public_notes) { return Utils::truncateString($this->public_notes, 16); } else { return '#' . $this->public_id; } } /** * @return mixed */ public function getDisplayName() { return $this->getName(); } /** * @return string */ public function getRoute() { return "/recurring_expenses/{$this->public_id}/edit"; } /** * @return mixed */ public function getEntityType() { return ENTITY_RECURRING_EXPENSE; } public function amountWithTax() { return $this->amount + Utils::calculateTaxes($this->amount, $this->tax_rate1, $this->tax_rate2); } } RecurringExpense::creating(function ($expense) { $expense->setNullValues(); }); RecurringExpense::created(function ($expense) { //event(new ExpenseWasCreated($expense)); }); RecurringExpense::updating(function ($expense) { $expense->setNullValues(); }); RecurringExpense::updated(function ($expense) { //event(new ExpenseWasUpdated($expense)); }); RecurringExpense::deleting(function ($expense) { $expense->setNullValues(); });