芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/app/Models/ExpenseCategory.php
hasMany(Expense::class); } public function company(): BelongsTo { return $this->belongsTo(Company::class); } public function getFormattedCreatedAtAttribute($value) { $dateFormat = CompanySetting::getSetting('carbon_date_format', $this->company_id); return Carbon::parse($this->created_at)->format($dateFormat); } public function getAmountAttribute() { return $this->expenses()->sum('amount'); } public function scopeWhereCompany($query) { $query->where('company_id', request()->header('company')); } public function scopeWhereCategory($query, $category_id) { $query->orWhere('id', $category_id); } public function scopeWhereSearch($query, $search) { $query->where('name', 'LIKE', '%'.$search.'%'); } public function scopeApplyFilters($query, array $filters) { $filters = collect($filters); if ($filters->get('category_id')) { $query->whereCategory($filters->get('category_id')); } if ($filters->get('company_id')) { $query->whereCompany($filters->get('company_id')); } if ($filters->get('search')) { $query->whereSearch($filters->get('search')); } } public function scopePaginateData($query, $limit) { if ($limit == 'all') { return $query->get(); } return $query->paginate($limit); } }