'object', 'custom_fields' => 'object', 'updated_at' => 'timestamp', 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', ]; protected $with = [ // 'tokens' ]; public function getCompanyIdAttribute() { return $this->encodePrimaryKey($this->id); } public function account() { return $this->belongsTo(Account::class); } public function users() { return $this->hasMany(CompanyUser::class); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function clients() { return $this->hasMany(Client::class); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function contacts() { return $this->hasMany(ClientContact::class); } public function groups() { return $this->hasMany(GroupSetting::class); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function invoices() { return $this->hasMany(Invoice::class); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function company_gateways() { return $this->hasMany(CompanyGateway::class)->orderBy('priority_id','ASC'); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function tax_rates() { return $this->hasMany(TaxRate::class); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function products() { return $this->hasMany(Product::class); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function country() { //return $this->belongsTo(Country::class); return Country::find($this->settings->country_id); } public function group_settings() { return $this->hasMany(GroupSetting::class); } /** * */ public function timezone() { return Timezone::find($this->settings->timezone_id); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function language() { return Language::find($this->settings->language_id); } public function getLocale() { return isset($this->settings->language_id) && $this->language() ? $this->language()->locale : config('ninja.i18n.locale'); } public function getLogo() { return $this->settings->company_logo ?: null; } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function currency() { return $this->belongsTo(Currency::class); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function industry() { return $this->belongsTo(Industry::class); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function payment_type() { return $this->belongsTo(PaymentType::class); } /** * @return mixed */ public function expenses() { return $this->hasMany(Expense::class, 'account_id', 'id')->withTrashed(); } /** * @return mixed */ public function payments() { return $this->hasMany(Payment::class, 'account_id', 'id')->withTrashed(); } public function tokens() { return $this->hasMany(CompanyToken::class); } public function company_users() { return $this->hasMany(CompanyUser::class); } public function owner() { $c = $this->company_users->where('is_owner',true)->first(); return User::find($c->user_id); } }