belongsTo(QuoteStage::class); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function quoteCarrier() { return $this->belongsTo(QuoteCarrier::class); } public function country() { return $this->belongsTo(Country::class); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function contact() { return $this->belongsTo(Contact::class); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function account() { return $this->belongsTo(Account::class); } public function deal() { return $this->belongsTo(Deal::class); } public function getGrossValueAttribute() { return $this->subtotal + $this->delivery_cost - $this->discount + $this->taxValue; } /** * Get Subtotal Value * @return string */ public function getSubtotalAttribute() { $subtotal = 0; foreach ($this->rows()->get() as $row) { $subtotal += $row->lineTotal; } return round($subtotal, 2); } public function tax() { return $this->belongsTo(Tax::class); } public function currency() { return $this->belongsTo(Currency::class); } public function rows() { return $this->hasMany(QuoteRow::class); } /** * Get Tax Value * @return string */ public function getTaxValueAttribute() { if ($this->tax != null) { $subtotal = $this->subtotal; return round((($subtotal + $this->delivery_cost - $this->discount) * $this->tax->tax_value), 2); } return 0; } public function company() { return $this->belongsTo(Company::class); } }