From 16634ccb8909d99e3940c3fe0cd867aad3cfed2b Mon Sep 17 00:00:00 2001 From: mh-asmi Date: Mon, 13 Jun 2022 23:26:24 +0300 Subject: [PATCH 1/6] Refactor: move haydrate and only parameters --- v5/Http/Resources/BaseResource.php | 52 ++++-------------------------- v5/Traits/HasHydrate.php | 48 +++++++++++++++++++++++++++ v5/Traits/HasOnlyParameters.php | 40 +++++++++++++++++++++++ 3 files changed, 94 insertions(+), 46 deletions(-) create mode 100644 v5/Traits/HasHydrate.php create mode 100644 v5/Traits/HasOnlyParameters.php diff --git a/v5/Http/Resources/BaseResource.php b/v5/Http/Resources/BaseResource.php index 66d1cdde20..bd4bd48f89 100644 --- a/v5/Http/Resources/BaseResource.php +++ b/v5/Http/Resources/BaseResource.php @@ -16,57 +16,17 @@ use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\Resource; +use v5\Traits\HasHydrate; +use v5\Traits\HasOnlyParameters; class BaseResource extends Resource { + use HasHydrate; + use HasOnlyParameters; + public static $wrap = 'result'; - public function getHydrate($relationships, Request $request) - { - $only_original = self::toHydrate($request, $relationships); - return array_filter($only_original, function ($o) use ($relationships) { - return in_array($o, $relationships); - }); - } - - public static function toHydrate(Request $request, $relationships) - { - $to_hydrate = $relationships; - if ($request->has('hydrate') && !$request->get('hydrate')) { - $to_hydrate = []; - } - if ($request->get('hydrate')) { - $to_hydrate = explode(',', $request->get('hydrate')); - } - return $to_hydrate; - } - - public static function onlyOriginal($request, $approved_fields) - { - $only_original = $approved_fields; - if ($request->query('format') === 'minimal') { - $only_original = ['id', 'name', 'description', 'translations']; - } elseif ($request->get('only')) { - $only_original = explode(',', $request->get('only')); - } - return $only_original; - } - - public static function includeFields($request, $approved_fields = []) - { - $fields = $approved_fields; - if ($request->has('only') && !$request->get('only')) { - return []; - } - $only_original = self::onlyOriginal($request, $approved_fields); - if (count($only_original) > 0) { - $fields = array_filter($only_original, function ($f) use ($approved_fields) { - return in_array($f, $approved_fields); - }); - } - return $fields; - } - + protected function setResourceFields($fields) { $result = []; diff --git a/v5/Traits/HasHydrate.php b/v5/Traits/HasHydrate.php new file mode 100644 index 0000000000..e65cfa241d --- /dev/null +++ b/v5/Traits/HasHydrate.php @@ -0,0 +1,48 @@ +has('hydrate') && !$request->get('hydrate')) { + $to_hydrate = []; + } + if ($request->get('hydrate')) { + + $to_hydrate = explode(',', $request->get('hydrate')); + } + return $to_hydrate; + } + + /** + * get the approved hedrate relationships + * + * @param array $relationships + * @param Request $request + * @return array + */ + public function getHydrate(array $relationships, Request $request):array + { + $only_original = self::toHydrate($request, $relationships); + return array_filter($only_original, function ($o) use ($relationships) { + return in_array($o, $relationships); + }); + } + + + + +} diff --git a/v5/Traits/HasOnlyParameters.php b/v5/Traits/HasOnlyParameters.php new file mode 100644 index 0000000000..fca960bbc5 --- /dev/null +++ b/v5/Traits/HasOnlyParameters.php @@ -0,0 +1,40 @@ + + */ + public static function onlyOriginal(Request $request,array $approved_fields): Array + { + $only_original = $approved_fields; + if ($request->query('format') === 'minimal') { + $only_original = ['id', 'name', 'description', 'translations']; + } elseif ($request->get('only')) { + $only_original = explode(',', $request->get('only')); + } + return $only_original; + } + + /** + * @return array + */ + public static function includeFields(Request $request, array $approved_fields = [],array $required_fields=[]):array + { + $only_fields = $approved_fields; + if ($request->has('only') && !$request->get('only')) { + return []; + } + $only_original = self::onlyOriginal($request, $approved_fields); + if (count($only_original) > 0) { + $only_fields = array_filter($only_original, function ($f) use ($approved_fields) { + return in_array($f, $approved_fields); + }); + } + return array_merge($required_fields,$only_fields); + } + +} From 9a6bb52f4a97a307726d91e4ca9d5a0df33fba9e Mon Sep 17 00:00:00 2001 From: mh-asmi Date: Tue, 14 Jun 2022 00:36:58 +0300 Subject: [PATCH 2/6] Feat: apply only parameters to Model --- v5/Http/Controllers/PostController.php | 8 ++++---- v5/Http/Controllers/SurveyController.php | 8 ++++---- v5/Models/BaseModel.php | 4 +++- v5/Models/Post/Post.php | 19 +++++++++++++++++++ v5/Models/Survey.php | 15 +++++++++++++++ 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/v5/Http/Controllers/PostController.php b/v5/Http/Controllers/PostController.php index cc12df5d32..c7dd2cead0 100644 --- a/v5/Http/Controllers/PostController.php +++ b/v5/Http/Controllers/PostController.php @@ -37,9 +37,9 @@ protected function ignoreInput() * @return mixed * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function show(int $id) + public function show(Request $request ,int $id) { - $post = Post::withPostValues()->where('id', $id)->first(); + $post = Post::withPostValues()->where('id', $id)->first(POST::SelectModelFields($request)); if (!$post) { return self::make404(); @@ -55,9 +55,9 @@ public function show(int $id) * @return PostCollection * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function index() + public function index(Request $request) { - return new PostCollection(Post::withPostValues()->paginate(20)); + return new PostCollection(Post::withPostValues()->paginate(20,POST::SelectModelFields($request))); } //end index() private function getUser() diff --git a/v5/Http/Controllers/SurveyController.php b/v5/Http/Controllers/SurveyController.php index 274fdba903..b7bc48f059 100644 --- a/v5/Http/Controllers/SurveyController.php +++ b/v5/Http/Controllers/SurveyController.php @@ -24,9 +24,9 @@ class SurveyController extends V5Controller * @return mixed * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function show(int $id) + public function show(Request $request,int $id) { - $survey = Survey::find($id); + $survey = Survey::find($id,Survey::SelectModelFields($request)); if (!$survey) { return self::make404(); } @@ -40,9 +40,9 @@ public function show(int $id) * @return SurveyCollection * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function index() + public function index(Request $request) { - return new SurveyCollection(Survey::all()); + return new SurveyCollection(Survey::all(Survey::SelectModelFields($request))); }//end index() /** diff --git a/v5/Models/BaseModel.php b/v5/Models/BaseModel.php index a92740a178..a55a51c8ec 100644 --- a/v5/Models/BaseModel.php +++ b/v5/Models/BaseModel.php @@ -6,6 +6,7 @@ use Illuminate\Support\Str; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\DB; +use v5\Traits\HasOnlyParameters; /** * Class ResourceModel @@ -14,7 +15,8 @@ */ class BaseModel extends Model { - + use HasOnlyParameters; + protected $validationRules = []; /** diff --git a/v5/Models/Post/Post.php b/v5/Models/Post/Post.php index 19d5e06f60..f8b6a78323 100644 --- a/v5/Models/Post/Post.php +++ b/v5/Models/Post/Post.php @@ -22,6 +22,7 @@ use Illuminate\Support\Facades\Input; use Ushahidi\App\Validator\LegacyValidator; use Ushahidi\Core\Tool\Permissions\InteractsWithPostPermissions; +use Illuminate\Http\Request; class Post extends BaseModel { @@ -673,4 +674,22 @@ public function postStages() { return $this->hasMany('v5\Models\PostStages', 'post_id', 'id'); } + + /** + * get the required cloumns . + * + * @param Request $request + * @return array + */ + public static function SelectModelFields(Request $request):array + { + return self::includeFields($request, (new Post())->fillable,[ + 'id', + 'parent_id', + 'base_language', + 'form_id', + 'status', + + ]); + } }//end class diff --git a/v5/Models/Survey.php b/v5/Models/Survey.php index dae0229760..8bfb939b8e 100644 --- a/v5/Models/Survey.php +++ b/v5/Models/Survey.php @@ -9,6 +9,8 @@ use Ushahidi\App\Validator\LegacyValidator; use Ushahidi\Core\Entity\Permission; use Ushahidi\Core\Tool\Permissions\InteractsWithFormPermissions; +use Illuminate\Http\Request; + class Survey extends BaseModel { @@ -449,4 +451,17 @@ public function setColorAttribute($value) $this->attributes['color'] = ltrim($value, '#'); } } + /** + * get the required columns . + * + * @param Request $request + * @return array + */ + public static function SelectModelFields(Request $request):array + { + return self::includeFields($request, (new Survey())->fillable,[ + 'id', + 'base_language', + ]); + } }//end class From 0cf79f0a45809600cbe32030555a54fe3aa146cc Mon Sep 17 00:00:00 2001 From: mh-asmi Date: Tue, 14 Jun 2022 11:02:12 +0300 Subject: [PATCH 3/6] Fix: apply clean code rules --- v5/Http/Controllers/PostController.php | 9 +++--- v5/Http/Controllers/SurveyController.php | 30 ++++++++++---------- v5/Models/Post/Post.php | 35 ++++++++++++------------ v5/Models/Survey.php | 28 +++++++++---------- v5/Traits/HasHydrate.php | 16 +++++------ v5/Traits/HasOnlyParameters.php | 28 ++++++++++++------- 6 files changed, 76 insertions(+), 70 deletions(-) diff --git a/v5/Http/Controllers/PostController.php b/v5/Http/Controllers/PostController.php index c7dd2cead0..3c7106b7c5 100644 --- a/v5/Http/Controllers/PostController.php +++ b/v5/Http/Controllers/PostController.php @@ -37,9 +37,9 @@ protected function ignoreInput() * @return mixed * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function show(Request $request ,int $id) + public function show(Request $request, int $id) { - $post = Post::withPostValues()->where('id', $id)->first(POST::SelectModelFields($request)); + $post = Post::withPostValues()->where('id', $id)->first(POST::selectModelFields($request)); if (!$post) { return self::make404(); @@ -57,7 +57,7 @@ public function show(Request $request ,int $id) */ public function index(Request $request) { - return new PostCollection(Post::withPostValues()->paginate(20,POST::SelectModelFields($request))); + return new PostCollection(Post::withPostValues()->paginate(20, POST::selectModelFields($request))); } //end index() private function getUser() @@ -430,7 +430,8 @@ protected function savePostValues(Post $post, array $post_content, int $post_id) } $class_name = "v5\Models\PostValues\Post" . ucfirst($type); - if (!class_exists($class_name) && + if ( + !class_exists($class_name) && in_array( $class_name, [ diff --git a/v5/Http/Controllers/SurveyController.php b/v5/Http/Controllers/SurveyController.php index b7bc48f059..bd12566e13 100644 --- a/v5/Http/Controllers/SurveyController.php +++ b/v5/Http/Controllers/SurveyController.php @@ -24,14 +24,14 @@ class SurveyController extends V5Controller * @return mixed * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function show(Request $request,int $id) + public function show(Request $request, int $id) { - $survey = Survey::find($id,Survey::SelectModelFields($request)); + $survey = Survey::find($id, Survey::selectModelFields($request)); if (!$survey) { return self::make404(); } return new SurveyResource($survey); - }//end show() + } //end show() /** @@ -42,8 +42,8 @@ public function show(Request $request,int $id) */ public function index(Request $request) { - return new SurveyCollection(Survey::all(Survey::SelectModelFields($request))); - }//end index() + return new SurveyCollection(Survey::all(Survey::selectModelFields($request))); + } //end index() /** * Display the specified resource. @@ -126,11 +126,11 @@ public function store(Request $request) 'field' ); } - }//end foreach - }//end if + } //end foreach + } //end if return new SurveyResource($survey); - }//end store() + } //end store() /** * Display the specified resource. @@ -172,7 +172,7 @@ public function update(int $id, Request $request) $survey->load('tasks'); return new SurveyResource($survey); - }//end update() + } //end update() /** * @param array $input_tasks @@ -207,7 +207,7 @@ private function updateTasks(array $input_tasks, Survey $survey) 'task' ); $this->updateFields(($stage['fields'] ?? []), $stage_model); - }//end foreach + } //end foreach $input_tasks_collection = new Collection($input_tasks); $survey->load('tasks'); @@ -219,7 +219,7 @@ private function updateTasks(array $input_tasks, Survey $survey) foreach ($tasks_to_delete as $task_to_delete) { Stage::where('id', $task_to_delete->id)->delete(); } - }//end updateTasks() + } //end updateTasks() private function isArrayOfNumbers(array $arr) { @@ -267,7 +267,7 @@ private function updateFields(array $input_fields, Stage $stage) ) ); $added_fields[] = $field_model->id; - }//end if + } //end if $this->updateTranslations( $field_model, @@ -276,7 +276,7 @@ private function updateFields(array $input_fields, Stage $stage) $field_model->id, 'field' ); - }//end foreach + } //end foreach $input_fields_collection = new Collection($input_fields); $stage->load('fields'); @@ -288,7 +288,7 @@ private function updateFields(array $input_fields, Stage $stage) foreach ($fields_to_delete as $field_to_delete) { Attribute::where('id', $field_to_delete->id)->delete(); } - }//end updateFields() + } //end updateFields() /** @@ -316,5 +316,5 @@ public function delete(int $id, Request $request) $survey->delete(); return response()->json(['result' => ['deleted' => $id]]); - }//end delete() + } //end delete() }//end class diff --git a/v5/Models/Post/Post.php b/v5/Models/Post/Post.php index f8b6a78323..390d90b995 100644 --- a/v5/Models/Post/Post.php +++ b/v5/Models/Post/Post.php @@ -1,4 +1,5 @@ 'report', 'locale' => 'en_US', @@ -221,7 +221,7 @@ public function validationMessages() ] ) ]; - }//end validationMessages() + } //end validationMessages() /** * Get the error messages for the defined *bulk* validation rules. @@ -248,7 +248,7 @@ private function bulkValidationMessages() ['field' => 'id'] ), ]; - }//end bulkValidationMessages() + } //end bulkValidationMessages() /** * Get the error messages for the defined *bulk* validation rules. @@ -274,7 +274,7 @@ public function bulkPatchValidationMessages() ) ] ); - }//end bulkValidationMessages() + } //end bulkValidationMessages() /** * Get the error messages for the defined *bulk* validation rules. @@ -309,7 +309,7 @@ public function getRules() 'title' => [ 'required', 'max:150', - 'regex:'.LegacyValidator::REGEX_STANDARD_TEXT, + 'regex:' . LegacyValidator::REGEX_STANDARD_TEXT, ], 'slug' => [ 'required', @@ -363,7 +363,7 @@ function ($attribute, $value, $fail) { 'locale', 'post_date' ]; - }//end getRules() + } //end getRules() /** * Get the post's translation. @@ -371,7 +371,7 @@ function ($attribute, $value, $fail) { public function translations() { return $this->morphMany('v5\Models\Translation', 'translatable'); - }//end translations() + } //end translations() public function getUserIdAttribute($value) @@ -559,7 +559,7 @@ protected static function valueTypesRelationships() 'Point', 'Relation', 'PostsMedia', -// 'PostsSet', + // 'PostsSet', 'PostTag' ]; return array_map(function ($t) { @@ -642,8 +642,7 @@ public function valuesMedia() public function valuesPoint() { - return $this->hasMany('v5\Models\PostValues\PostPoint', 'post_id', 'id'); - ; + return $this->hasMany('v5\Models\PostValues\PostPoint', 'post_id', 'id');; } public function valuesRelation() @@ -674,22 +673,22 @@ public function postStages() { return $this->hasMany('v5\Models\PostStages', 'post_id', 'id'); } - + /** * get the required cloumns . * * @param Request $request * @return array */ - public static function SelectModelFields(Request $request):array + public static function selectModelFields(Request $request): array { - return self::includeFields($request, (new Post())->fillable,[ - 'id', + return self::includeFields($request, (new Post())->fillable, [ + 'id', 'parent_id', 'base_language', 'form_id', 'status', - + ]); } }//end class diff --git a/v5/Models/Survey.php b/v5/Models/Survey.php index 8bfb939b8e..8dbee1e228 100644 --- a/v5/Models/Survey.php +++ b/v5/Models/Survey.php @@ -238,7 +238,7 @@ public function validationMessages() // [[$this, 'canMakePrivate'], [':value', $type]] // ] ]; - }//end validationMessages() + } //end validationMessages() /** * Return all validation rules @@ -252,7 +252,7 @@ public function getRules() 'required', 'min:2', 'max:255', - 'regex:'.LegacyValidator::REGEX_STANDARD_TEXT, + 'regex:' . LegacyValidator::REGEX_STANDARD_TEXT, ], 'description' => [ 'string', @@ -270,7 +270,7 @@ public function getRules() 'targeted_survey' => ['boolean'], 'tasks.*.label' => [ 'required', - 'regex:'.LegacyValidator::REGEX_STANDARD_TEXT, + 'regex:' . LegacyValidator::REGEX_STANDARD_TEXT, ], 'tasks.*.type' => [Rule::in( [ @@ -350,7 +350,7 @@ function ($attribute, $value, $fail) { // should be removing that arbitrary limit since it's pretty rare // for it to be needed ]; - }//end getRules() + } //end getRules() public function canMakePrivate($value, $type) { @@ -381,7 +381,7 @@ public function getCanCreateAttribute() { $can_create = $this->getCanCreateRoles($this->id); return $can_create['roles']; - }//end getCanCreateAttribute() + } //end getCanCreateAttribute() private function getCanCreateRoles($form_id) @@ -394,7 +394,7 @@ private function getCanCreateRoles($form_id) */ $form_repo = service('repository.form'); return $form_repo->getRolesThatCanCreatePosts($form_id); - }//end getCanCreateRoles() + } //end getCanCreateRoles() /** @@ -416,9 +416,9 @@ public function tasks() 'v5\Models\Stage', 'form_id' ) - ->where('form_stages.show_when_published', '=', '1') - ->where('form_stages.task_is_internal_only', '=', '0'); - }//end tasks() + ->where('form_stages.show_when_published', '=', '1') + ->where('form_stages.task_is_internal_only', '=', '0'); + } //end tasks() /** @@ -427,7 +427,7 @@ public function tasks() public function translations() { return $this->morphMany('v5\Models\Translation', 'translatable'); - }//end translations() + } //end translations() /** * Get the survey color. @@ -451,16 +451,16 @@ public function setColorAttribute($value) $this->attributes['color'] = ltrim($value, '#'); } } - /** + /** * get the required columns . * * @param Request $request * @return array */ - public static function SelectModelFields(Request $request):array + public static function selectModelFields(Request $request): array { - return self::includeFields($request, (new Survey())->fillable,[ - 'id', + return self::includeFields($request, (new Survey())->fillable, [ + 'id', 'base_language', ]); } diff --git a/v5/Traits/HasHydrate.php b/v5/Traits/HasHydrate.php index e65cfa241d..65c2a2f701 100644 --- a/v5/Traits/HasHydrate.php +++ b/v5/Traits/HasHydrate.php @@ -1,11 +1,13 @@ has('hydrate') && !$request->get('hydrate')) { $to_hydrate = []; } if ($request->get('hydrate')) { - + $to_hydrate = explode(',', $request->get('hydrate')); } return $to_hydrate; @@ -34,15 +36,11 @@ private static function toHydrate(Request $request, array $relationships) * @param Request $request * @return array */ - public function getHydrate(array $relationships, Request $request):array + public function getHydrate(array $relationships, Request $request): array { $only_original = self::toHydrate($request, $relationships); return array_filter($only_original, function ($o) use ($relationships) { return in_array($o, $relationships); }); } - - - - } diff --git a/v5/Traits/HasOnlyParameters.php b/v5/Traits/HasOnlyParameters.php index fca960bbc5..75aeada048 100644 --- a/v5/Traits/HasOnlyParameters.php +++ b/v5/Traits/HasOnlyParameters.php @@ -1,14 +1,19 @@ - */ - public static function onlyOriginal(Request $request,array $approved_fields): Array + * get only fields from the request + * @param Request $request + * @param array $approved_fields + * @return array + */ + public static function onlyOriginal(Request $request, array $approved_fields): array { $only_original = $approved_fields; if ($request->query('format') === 'minimal') { @@ -18,11 +23,15 @@ public static function onlyOriginal(Request $request,array $approved_fields): Ar } return $only_original; } - + /** - * @return array - */ - public static function includeFields(Request $request, array $approved_fields = [],array $required_fields=[]):array + * get the approved only fields + * @param Request $request + * @param array $approved_fields + * @param array $required_fields + * @return array + */ + public static function includeFields(Request $request, array $approved_fields = [], array $required_fields = []): array { $only_fields = $approved_fields; if ($request->has('only') && !$request->get('only')) { @@ -34,7 +43,6 @@ public static function includeFields(Request $request, array $approved_fields = return in_array($f, $approved_fields); }); } - return array_merge($required_fields,$only_fields); + return array_merge($required_fields, $only_fields); } - } From 70989f465da4ae9e503b11fb945576c8656d7850 Mon Sep 17 00:00:00 2001 From: mh-asmi Date: Tue, 14 Jun 2022 15:33:31 +0300 Subject: [PATCH 4/6] fix: linting errors --- v5/Http/Controllers/PostController.php | 3 +-- v5/Models/Post/Post.php | 4 ++-- v5/Models/Survey.php | 3 +-- v5/Traits/HasHydrate.php | 2 -- v5/Traits/HasOnlyParameters.php | 1 - 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/v5/Http/Controllers/PostController.php b/v5/Http/Controllers/PostController.php index 3c7106b7c5..d2ad5f4599 100644 --- a/v5/Http/Controllers/PostController.php +++ b/v5/Http/Controllers/PostController.php @@ -430,8 +430,7 @@ protected function savePostValues(Post $post, array $post_content, int $post_id) } $class_name = "v5\Models\PostValues\Post" . ucfirst($type); - if ( - !class_exists($class_name) && + if (!class_exists($class_name) && in_array( $class_name, [ diff --git a/v5/Models/Post/Post.php b/v5/Models/Post/Post.php index 390d90b995..994e9b9b99 100644 --- a/v5/Models/Post/Post.php +++ b/v5/Models/Post/Post.php @@ -642,7 +642,7 @@ public function valuesMedia() public function valuesPoint() { - return $this->hasMany('v5\Models\PostValues\PostPoint', 'post_id', 'id');; + return $this->hasMany('v5\Models\PostValues\PostPoint', 'post_id', 'id'); } public function valuesRelation() @@ -675,7 +675,7 @@ public function postStages() } /** - * get the required cloumns . + * get the required cloumns . * * @param Request $request * @return array diff --git a/v5/Models/Survey.php b/v5/Models/Survey.php index 8dbee1e228..28b3d29489 100644 --- a/v5/Models/Survey.php +++ b/v5/Models/Survey.php @@ -11,7 +11,6 @@ use Ushahidi\Core\Tool\Permissions\InteractsWithFormPermissions; use Illuminate\Http\Request; - class Survey extends BaseModel { use InteractsWithFormPermissions; @@ -452,7 +451,7 @@ public function setColorAttribute($value) } } /** - * get the required columns . + * get the required columns . * * @param Request $request * @return array diff --git a/v5/Traits/HasHydrate.php b/v5/Traits/HasHydrate.php index 65c2a2f701..6314e77e7f 100644 --- a/v5/Traits/HasHydrate.php +++ b/v5/Traits/HasHydrate.php @@ -4,7 +4,6 @@ use Illuminate\Http\Request; - trait HasHydrate { /** @@ -23,7 +22,6 @@ private static function toHydrate(Request $request, array $relationships) $to_hydrate = []; } if ($request->get('hydrate')) { - $to_hydrate = explode(',', $request->get('hydrate')); } return $to_hydrate; diff --git a/v5/Traits/HasOnlyParameters.php b/v5/Traits/HasOnlyParameters.php index 75aeada048..5258e381fe 100644 --- a/v5/Traits/HasOnlyParameters.php +++ b/v5/Traits/HasOnlyParameters.php @@ -4,7 +4,6 @@ use Illuminate\Http\Request; - trait HasOnlyParameters { /** From be1bf9915e16f115a5c7767fd3ca8f1f3f8ef976 Mon Sep 17 00:00:00 2001 From: mh-asmi Date: Thu, 16 Jun 2022 04:11:51 -0700 Subject: [PATCH 5/6] fix: line length --- v5/Traits/HasOnlyParameters.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v5/Traits/HasOnlyParameters.php b/v5/Traits/HasOnlyParameters.php index 5258e381fe..444735dc1d 100644 --- a/v5/Traits/HasOnlyParameters.php +++ b/v5/Traits/HasOnlyParameters.php @@ -30,7 +30,7 @@ public static function onlyOriginal(Request $request, array $approved_fields): a * @param array $required_fields * @return array */ - public static function includeFields(Request $request, array $approved_fields = [], array $required_fields = []): array + public static function includeFields(Request $request, array $approved_fields = [], array $required_fields = []) { $only_fields = $approved_fields; if ($request->has('only') && !$request->get('only')) { From 67df3b9f71a0b5bb94693283e8a47657e3269900 Mon Sep 17 00:00:00 2001 From: Mh-Asmi Date: Mon, 27 Jun 2022 13:45:57 +0300 Subject: [PATCH 6/6] Fix: resolve conflict in model survey --- v5/Models/Survey.php | 1 - 1 file changed, 1 deletion(-) diff --git a/v5/Models/Survey.php b/v5/Models/Survey.php index 1079d7dff1..4f2e063674 100644 --- a/v5/Models/Survey.php +++ b/v5/Models/Survey.php @@ -6,7 +6,6 @@ use Ushahidi\Contracts\Permission; use Illuminate\Support\Facades\Input; use Ushahidi\App\Validator\LegacyValidator; -use Ushahidi\Core\Entity\Permission; use Ushahidi\Core\Tools\Permissions\InteractsWithFormPermissions; use Illuminate\Http\Request;