id) ->get(); } public function getLogoPathAttribute() { $logo = $this->getMedia('logo')->first(); $isSystem = FileDisk::whereSetAsDefault(true)->first()->isSystem(); if ($logo) { if ($isSystem) { return $logo->getPath(); } else { return $logo->getFullUrl(); } } return null; } public function getLogoAttribute() { $logo = $this->getMedia('logo')->first(); if ($logo) { return $logo->getFullUrl(); } return null; } public function customers(): HasMany { return $this->hasMany(Customer::class); } public function owner(): BelongsTo { return $this->belongsTo(User::class, 'owner_id'); } public function settings(): HasMany { return $this->hasMany(CompanySetting::class); } public function recurringInvoices(): HasMany { return $this->hasMany(RecurringInvoice::class); } public function customFields(): HasMany { return $this->hasMany(CustomField::class); } public function customFieldValues(): HasMany { return $this->hasMany(CustomFieldValue::class); } public function exchangeRateLogs(): HasMany { return $this->hasMany(ExchangeRateLog::class); } public function exchangeRateProviders(): HasMany { return $this->hasMany(ExchangeRateProvider::class); } public function invoices(): HasMany { return $this->hasMany(Invoice::class); } public function expenses(): HasMany { return $this->hasMany(Expense::class); } public function units(): HasMany { return $this->hasMany(Unit::class); } public function expenseCategories(): HasMany { return $this->hasMany(ExpenseCategory::class); } public function taxTypes(): HasMany { return $this->hasMany(TaxType::class); } public function items(): HasMany { return $this->hasMany(Item::class); } public function payments(): HasMany { return $this->hasMany(Payment::class); } public function paymentMethods(): HasMany { return $this->hasMany(PaymentMethod::class); } public function estimates(): HasMany { return $this->hasMany(Estimate::class); } public function address(): HasOne { return $this->hasOne(Address::class); } public function users(): BelongsToMany { return $this->belongsToMany(User::class, 'user_company', 'company_id', 'user_id'); } public function hasTransactions() { if ( $this->customers()->exists() || $this->items()->exists() || $this->invoices()->exists() || $this->estimates()->exists() || $this->expenses()->exists() || $this->payments()->exists() || $this->recurringInvoices()->exists() ) { return true; } return false; } }