$documents * @property-read int|null $documents_count * @property-read mixed $hashed_id * @property-read \App\Models\PaymentType|null $payment_type * @property-read \App\Models\Project|null $project * @property-read \App\Models\PurchaseOrder|null $purchase_order * @property-read \App\Models\User $user * @property-read \App\Models\Vendor|null $vendor * @method static \Illuminate\Database\Eloquent\Builder|BaseModel company() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns) * @method static \Database\Factories\ExpenseFactory factory($count = null, $state = []) * @method static \Illuminate\Database\Eloquent\Builder|Expense filter(\App\Filters\QueryFilters $filters) * @method static \Illuminate\Database\Eloquent\Builder|Expense newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Expense newQuery() * @method static \Illuminate\Database\Eloquent\Builder|Expense onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Expense query() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() * @method static \Illuminate\Database\Eloquent\Builder|Expense withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Expense withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $documents * @property-read \App\Models\Invoice|null $invoice * @property-read \App\Models\BankTransaction|null $transaction * @mixin \Eloquent */ class Expense extends BaseModel { use SoftDeletes; use Filterable; protected $fillable = [ 'client_id', 'assigned_user_id', 'vendor_id', 'invoice_id', 'currency_id', 'date', 'invoice_currency_id', 'amount', 'foreign_amount', 'exchange_rate', 'private_notes', 'public_notes', 'bank_id', 'transaction_id', 'category_id', 'tax_rate1', 'tax_name1', 'tax_rate2', 'tax_name2', 'tax_rate3', 'tax_name3', 'payment_date', 'payment_type_id', 'project_id', 'transaction_reference', 'invoice_documents', 'should_be_invoiced', 'custom_value1', 'custom_value2', 'custom_value3', 'custom_value4', 'number', 'tax_amount1', 'tax_amount2', 'tax_amount3', 'uses_inclusive_taxes', 'calculate_tax_by_amount', 'purchase_order_id', ]; protected $casts = [ 'is_deleted' => 'boolean', 'updated_at' => 'timestamp', 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', ]; protected $touches = []; public function getEntityType() { return self::class; } /** * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany { return $this->morphMany(Document::class, 'documentable'); } public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class)->withTrashed(); } public function assigned_user(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed(); } public function company() { return $this->belongsTo(Company::class); } public function invoice(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Invoice::class); } public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Vendor::class); } public function client(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Client::class); } public function purchase_order() { return $this->hasOne(PurchaseOrder::class); } public function translate_entity() { return ctrans('texts.expense'); } public function currency(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Currency::class); } public function category(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(ExpenseCategory::class)->withTrashed(); } public function payment_type(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(PaymentType::class); } public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Project::class); } public function transaction(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(BankTransaction::class); } public function stringStatus() { if($this->is_deleted) return ctrans('texts.deleted'); elseif($this->payment_date) return ctrans('texts.paid'); elseif($this->invoice_id) return ctrans('texts.invoiced'); elseif($this->should_be_invoiced) return ctrans('texts.pending'); elseif($this->trashed()) return ctrans('texts.archived'); return ctrans('texts.logged'); } }