belongsTo('App\Models\Invoice'); } /** * @return mixed */ public function user() { return $this->belongsTo('App\Models\User')->withTrashed(); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function product() { return $this->belongsTo('App\Models\Product'); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function account() { return $this->belongsTo('App\Models\Account'); } public function amount() { $amount = $this->cost * $this->qty; $preTaxAmount = $amount; if ($this->tax_rate1) { $amount += $preTaxAmount * $this->tax_rate1 / 100; } if ($this->tax_rate2) { $amount += $preTaxAmount * $this->tax_rate2 / 100; } return $amount; } public function markFeePaid() { if ($this->invoice_item_type_id == INVOICE_ITEM_TYPE_PENDING_GATEWAY_FEE) { $this->invoice_item_type_id = INVOICE_ITEM_TYPE_PAID_GATEWAY_FEE; $this->save(); } } }