芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Models/Company.php
'string' ]; protected $appends = [ 'logo_url', 'login_background_url', 'moment_date_format', 'favicon_url' ]; const DATE_FORMATS = GlobalSetting::DATE_FORMATS; public function currency(): BelongsTo { return $this->belongsTo(Currency::class, 'currency_id'); } public function package(): BelongsTo { return $this->belongsTo(Package::class, 'package_id'); } public function users() { return $this->hasMany(User::class)->withoutGlobalScope(CompanyScope::class)->withoutGlobalScope('active'); } public function user() { return $this->hasOne(User::class)->withoutGlobalScopes([CompanyScope::class, ActiveScope::class])->setEagerLoads([]); } public static function firstActiveAdmin($company) { $admins = Role::with('users')->where('name', 'admin')->where('company_id', $company->id)->first(); return $admins->users->first(); } public function employees() { return $this->hasMany(User::class)->whereHas('employeeDetail'); } public function getLogoUrlAttribute() { if (user()) { if (user()->dark_theme) { return $this->defaultLogo(); } } if (company() && company()->auth_theme == 'dark') { return $this->defaultLogo(); } if (is_null($this->light_logo)) { return global_setting()->light_logo_url; } return asset_url_local_s3('app-logo/' . $this->light_logo); } public function defaultLogo() { if (is_null($this->logo)) { return global_setting()->dark_logo_url; } return asset_url_local_s3('app-logo/' . $this->logo); } public function getLightLogoUrlAttribute() { if (is_null($this->light_logo)) { return global_setting()->light_logo_url; } return asset_url_local_s3('app-logo/' . $this->light_logo); } public function getDarkLogoUrlAttribute() { if (is_null($this->logo)) { return asset('img/worksuite-logo.png'); } return asset_url_local_s3('app-logo/' . $this->logo); } public function getLoginBackgroundUrlAttribute() { if (is_null($this->login_background) || $this->login_background == 'login-background.jpg') { return null; } return asset_url_local_s3('login-background/' . $this->login_background); } public function maskedDefaultLogo(): Attribute { return Attribute::make( get: function () { if (is_null($this->logo)) { return global_setting()->dark_logo_url; } return $this->generateMaskedImageAppUrl('app-logo/' . $this->logo); }, ); } public function maskedLogoUrl(): Attribute { return Attribute::make( get: function () { if (user()) { if (user()->dark_theme) { return $this->masked_default_logo; } } if (company() && company()->auth_theme == 'dark') { return $this->masked_default_logo; } if (is_null($this->light_logo)) { return global_setting()->light_logo_url; } return $this->generateMaskedImageAppUrl('app-logo/' . $this->light_logo); }, ); } public function maskedLightLogoUrl(): Attribute { return Attribute::make( get: function () { if (is_null($this->light_logo)) { return global_setting()->light_logo_url; } return $this->generateMaskedImageAppUrl('app-logo/' . $this->light_logo); }, ); } public function maskedDarkLogoUrl(): Attribute { return Attribute::make( get: function () { if (is_null($this->logo)) { return asset('img/worksuite-logo.png'); } return $this->generateMaskedImageAppUrl('app-logo/' . $this->logo); }, ); } public function maskedLoginBackgroundUrl(): Attribute { return Attribute::make( get: function () { if (is_null($this->login_background) || $this->login_background == 'login-background.jpg') { return null; } return $this->generateMaskedImageAppUrl('login-background/' . $this->login_background); }, ); } public function maskedFaviconUrl(): Attribute { return Attribute::make( get: function () { if (is_null($this->favicon)) { return global_setting()->favicon_url; } return $this->generateMaskedImageAppUrl('favicon/' . $this->favicon); }, ); } public function getMomentDateFormatAttribute() { return isset($this->date_format) ? self::DATE_FORMATS[$this->date_format] : null; } public function getFaviconUrlAttribute() { if (is_null($this->favicon)) { return global_setting()->favicon_url; } return asset_url_local_s3('favicon/' . $this->favicon); } public function paymentGatewayCredentials(): HasOne { return $this->hasOne(PaymentGatewayCredentials::class); } public function invoiceSetting(): HasOne { return $this->hasOne(InvoiceSetting::class); } public function offlinePaymentMethod(): HasMany { return $this->hasMany(OfflinePaymentMethod::class); } public function leaveTypes() { return $this->hasMany(LeaveType::class); } public function companyAddress(): HasMany { return $this->hasMany(CompanyAddress::class); } public function defaultAddress(): HasOne { return $this->hasOne(CompanyAddress::class)->where('is_default', 1); } public function taxes(): HasMany { return $this->hasMany(Tax::class); } public function ticketTypes(): HasMany { return $this->hasMany(TicketType::class); } public function ticketChannels(): HasMany { return $this->hasMany(TicketChannel::class); } public function projectSetting(): HasOne { return $this->hasOne(ProjectSetting::class); } public function projectStatusSettings(): HasMany { return $this->HasMany(ProjectStatusSetting::class); } public function attendanceSetting(): HasOne { return $this->HasOne(AttendanceSetting::class); } public function messageSetting(): HasOne { return $this->HasOne(MessageSetting::class); } public function leadSources(): HasMany { return $this->HasMany(LeadSource::class); } public function leadStats(): HasMany { return $this->HasMany(LeadStatus::class); } public function leadAgents(): HasMany { return $this->HasMany(LeadAgent::class); } public function leadCategories(): HasMany { return $this->HasMany(LeadCategory::class); } public function moduleSetting(): HasMany { return $this->HasMany(ModuleSetting::class); } public function currencies(): HasMany { return $this->HasMany(Currency::class); } public function timeLogSetting(): HasOne { return $this->HasOne(ProjectTimeLog::class); } public function taskSetting(): HasOne { return $this->HasOne(TaskSetting::class); } public function leaveSetting(): HasOne { return $this->HasOne(LeaveSetting::class); } public function slackSetting(): HasOne { return $this->HasOne(SlackSetting::class); } public function fileStorage() { return $this->hasMany(FileStorage::class); } public static function renameOrganisationTableToCompanyTable() { if (Schema::hasTable('organisation_settings')) { Schema::rename('organisation_settings', 'companies'); } } public function clients() { return $this->hasMany(User::class)->whereHas('ClientDetails'); } public function invoices() { return $this->hasMany(Invoice::class); } public function estimates() { return $this->hasMany(Estimate::class); } public function projects() { return $this->hasMany(Project::class); } public function tasks() { return $this->hasMany(Task::class); } public function leads() { return $this->hasMany(Lead::class); } public function orders() { return $this->hasMany(Order::class); } public function tickets() { return $this->hasMany(Ticket::class); } public function contracts() { return $this->hasMany(Contract::class); } // WORKSUITESAAS public function approvalBy() { return $this->belongsTo(User::class, 'approved_by'); } public function scopeActive($query) { return $query->where('status', 'active'); } }