$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 \Illuminate\Database\Eloquent\Collection $client * @property-read \Illuminate\Database\Eloquent\Collection $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; } public function documents() { return $this->morphMany(Document::class, 'documentable'); } public function user() { return $this->belongsTo(User::class)->withTrashed(); } public function assigned_user() { return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed(); } public function company() { return $this->belongsTo(Company::class); } public function invoice() { return $this->belongsTo(Invoice::class); } public function vendor() { return $this->belongsTo(Vendor::class); } public function client() { 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() { return $this->belongsTo(Currency::class); } public function category() { return $this->belongsTo(ExpenseCategory::class)->withTrashed(); } public function payment_type() { return $this->belongsTo(PaymentType::class); } public function project() { return $this->belongsTo(Project::class); } public function transaction() { 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'); } }