芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Models/Expense.php
$transactions * @property-read int|null $transactions_count * @method static \Illuminate\Database\Eloquent\Builder|Expense whereBankAccountId($value) * @method static \Illuminate\Database\Eloquent\Builder|Expense whereDefaultCurrencyId($value) * @method static \Illuminate\Database\Eloquent\Builder|Expense whereExchangeRate($value) * @property-read \Illuminate\Database\Eloquent\Collection
$mentionUser * @property-read int|null $mention_user_count * @property-read \Illuminate\Database\Eloquent\Collection
$transactions * @mixin \Eloquent */ class Expense extends BaseModel { use CustomFieldsTrait, HasFactory, HasCompany; const FILE_PATH = 'expense-invoice'; const CUSTOM_FIELD_MODEL = 'App\Models\Expense'; protected $casts = [ 'purchase_date' => 'datetime', 'purchase_on' => 'datetime', ]; protected $appends = ['total_amount', 'purchase_on', 'bill_url', 'default_currency_price']; protected $with = ['currency', 'company:id']; public function getBillUrlAttribute() { return ($this->bill) ? asset_url_local_s3(Expense::FILE_PATH . '/' . $this->bill) : ''; } public function currency(): BelongsTo { return $this->belongsTo(Currency::class, 'currency_id'); } public function project(): BelongsTo { return $this->belongsTo(Project::class, 'project_id'); } public function category(): BelongsTo { return $this->belongsTo(ExpensesCategory::class, 'category_id'); } public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id')->withoutGlobalScope(ActiveScope::class); } public function approver(): BelongsTo { return $this->belongsTo(User::class, 'approver_id')->withoutGlobalScope(ActiveScope::class); } public function recurrings(): HasMany { return $this->hasMany(Expense::class, 'parent_id'); } public function transactions(): HasMany { return $this->hasMany(BankTransaction::class, 'expense_id'); } public function getTotalAmountAttribute() { if (!is_null($this->price) && !is_null($this->currency_id)) { return currency_format($this->price, $this->currency_id); } return ''; } public function getPurchaseOnAttribute() { if (is_null($this->purchase_date)) { return ''; } return $this->purchase_date->format($this->company ? $this->company->date_format : company()->date_format); } public function mentionUser(): BelongsToMany { return $this->belongsToMany(User::class, 'mention_users')->withoutGlobalScope(ActiveScope::class)->using(MentionUser::class); } public function defaultCurrencyPrice() : Attribute { return Attribute::make( get: function () { if ($this->currency_id == company()->currency_id) { return $this->price; } if(!$this->exchange_rate){ return $this->price; } return (($this->price * (float)$this->exchange_rate) / company()->currency->exchange_rate); }, ); } }