'object', 'updated_at' => 'timestamp', 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', ]; const STATUS_DRAFT = 1; const STAUS_PARTIAL = 2; const STATUS_APPLIED = 3; public function assigned_user() { return $this->belongsTo(User::class, 'assigned_user_id', 'id'); } public function company() { return $this->belongsTo(Company::class); } public function user() { return $this->belongsTo(User::class)->withTrashed(); } public function client() { return $this->belongsTo(Client::class)->withTrashed(); } public function invitations() { return $this->hasMany(CreditInvitation::class); } /** * The invoice which the credit has been created from */ public function invoice() { return $this->belongsTo(Invoice::class); } /** * The invoice/s which the credit has * been applied to. */ public function invoices() { return $this->belongsToMany(Invoice::class)->using(Paymentable::class); } public function payments() { return $this->morphToMany(Payment::class, 'paymentable'); } /** * Access the invoice calculator object * * @return object The invoice calculator object getters */ public function calc() { $credit_calc = null; if ($this->uses_inclusive_taxes) { $credit_calc = new InvoiceSumInclusive($this); } else { $credit_calc = new InvoiceSum($this); } return $credit_calc->build(); } }