From 81da8e169d4229a50689eb288742a54105a51225 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 18 Jan 2021 22:06:26 +1100 Subject: [PATCH] Add documents to groups --- app/Http/Controllers/GroupSettingController.php | 5 +++++ app/Models/GroupSetting.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/Http/Controllers/GroupSettingController.php b/app/Http/Controllers/GroupSettingController.php index 1f79f7838d..8f7f828270 100644 --- a/app/Http/Controllers/GroupSettingController.php +++ b/app/Http/Controllers/GroupSettingController.php @@ -22,6 +22,7 @@ use App\Models\GroupSetting; use App\Repositories\GroupSettingRepository; use App\Transformers\GroupSettingTransformer; use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; use App\Utils\Traits\Uploadable; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Http\Request; @@ -32,6 +33,7 @@ class GroupSettingController extends BaseController use DispatchesJobs; use Uploadable; use MakesHash; + use SavesDocuments; protected $entity_type = GroupSetting::class; @@ -357,6 +359,9 @@ class GroupSettingController extends BaseController $this->uploadLogo($request->file('company_logo'), $group_setting->company, $group_setting); + if ($request->has('documents')) + $this->saveDocuments($request->input('documents'), $group_setting, false); + return $this->itemResponse($group_setting); } diff --git a/app/Models/GroupSetting.php b/app/Models/GroupSetting.php index 14d4178a37..b94fffbbfd 100644 --- a/app/Models/GroupSetting.php +++ b/app/Models/GroupSetting.php @@ -51,6 +51,11 @@ class GroupSetting extends StaticModel return $this->hasMany(Client::class, 'id', 'group_settings_id'); } + public function documents() + { + return $this->morphMany(Document::class, 'documentable'); + } + /** * Retrieve the model for a bound value. *