diff --git a/app/Models/Company.php b/app/Models/Company.php index d18303ddd262..e34d25a228b1 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -112,6 +112,11 @@ class Company extends BaseModel return $this->hasMany(ClientContact::class); } + public function groups() + { + return $this->hasMany(GroupSetting::class); + } + /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index d8dddafbf928..f3b5049bb789 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -16,8 +16,10 @@ use App\Models\Account; use App\Models\Client; use App\Models\Company; use App\Models\CompanyUser; +use App\Models\GroupSetting; use App\Models\User; use App\Transformers\CompanyUserTransformer; +use App\Transformers\GroupSettingTransformer; use App\Utils\Traits\MakesHash; /** @@ -50,6 +52,7 @@ class CompanyTransformer extends EntityTransformer 'expenses', 'payments', 'company_user', + 'groups' ]; @@ -88,7 +91,6 @@ class CompanyTransformer extends EntityTransformer $transformer = new CompanyUserTransformer($this->serializer); return $this->includeItem($company->company_users->where('user_id', auth()->user()->id)->first(), $transformer, CompanyUser::class); - } public function includeUsers(Company $company) @@ -105,6 +107,13 @@ class CompanyTransformer extends EntityTransformer return $this->includeCollection($company->clients, $transformer, Client::class); } + public function includeGroups(Company $company) + { + $transformer = new GroupSettingTransformer($this->serializer); + + return $this->includeCollection($company->groups, $transformer, GroupSetting::class); + } + public function includeInvoices(Company $company) { $transformer = new InvoiceTransformer($this->serializer); diff --git a/app/Transformers/GroupSettingTransformer.php b/app/Transformers/GroupSettingTransformer.php new file mode 100644 index 000000000000..43b4d73a91dc --- /dev/null +++ b/app/Transformers/GroupSettingTransformer.php @@ -0,0 +1,47 @@ + $this->encodePrimaryKey($group_setting->id), + 'name' => $group_setting->name ?: '', + 'settings' => $group_setting->settings ?: '', + ]; + } +} \ No newline at end of file diff --git a/app/Utils/Statics.php b/app/Utils/Statics.php index 1ea46991cab6..27a382564904 100644 --- a/app/Utils/Statics.php +++ b/app/Utils/Statics.php @@ -85,7 +85,6 @@ class Statics return $industry->name; })->values(); - $data['countries'] = Cache::get('countries')->each(function ($country) { $country->name = ctrans('texts.country_'.$country->name); })->sortBy(function ($country) { diff --git a/config/ninja.php b/config/ninja.php index 086ec86fdb39..f94cc3ed921e 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -68,8 +68,8 @@ return [ 'sizes' => 'App\Models\Size', 'industries' => 'App\Models\Industry', 'timezones' => 'App\Models\Timezone', - //'dateFormats' => 'App\Models\DateFormat', - //'datetimeFormats' => 'App\Models\DatetimeFormat', + 'dateFormats' => 'App\Models\DateFormat', + 'datetimeFormats' => 'App\Models\DatetimeFormat', 'languages' => 'App\Models\Language', 'payment_types' => 'App\Models\PaymentType', 'countries' => 'App\Models\Country',