'object', 'updated_at' => 'timestamp', 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', 'is_deleted' => 'bool', ]; public function client() { return $this->belongsTo(Client::class); } public function company() { return $this->belongsTo(Company::class); } public function user() { return $this->belongsTo(User::class); } public function assigned_user() { return $this->belongsTo(User::class ,'assigned_user_id', 'id'); } public function documents() { return $this->morphMany(Document::class, 'documentable'); } public function invoices() { return $this->morphedByMany(Invoice::class, 'paymentable')->withPivot('amount'); } public function company_ledger() { return $this->morphMany(CompanyLedger::class, 'company_ledgerable'); } public function type() { return $this->hasOne(PaymentType::class,'id','payment_type_id'); } public function formattedAmount() { return Number::formatMoney($this->amount, $this->client); } public function clientPaymentDate() { if(!$this->payment_date) return ''; $date_format = DateFormat::find($this->client->getSetting('date_format_id')); return $this->createClientDate($this->payment_date, $this->client->timezone()->name)->format($date_format->format); } public static function badgeForStatus(int $status) { switch ($status) { case self::STATUS_PENDING: return '
'.ctrans('texts.payment_status_1').'
'; break; case self::STATUS_VOIDED: return '
'.ctrans('texts.payment_status_2').'
'; break; case self::STATUS_FAILED: return '
'.ctrans('texts.payment_status_3').'
'; break; case self::STATUS_COMPLETED: return '
'.ctrans('texts.payment_status_4').'
'; break; case self::STATUS_PARTIALLY_REFUNDED: return '
'.ctrans('texts.payment_status_5').'
'; break; case self::STATUS_REFUNDED: return '
'.ctrans('texts.payment_status_6').'
'; break; default: # code... break; } } public function resolveRouteBinding($value) { return $this ->withTrashed() ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); } }