From 7d03d455271e103603398aa699cf0c10f57cbf1f Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Sat, 21 Mar 2020 15:34:23 +0300 Subject: [PATCH 1/5] validation rules should be seperated from attributes --- app/Http/Requests/Setting/Module.php | 4 ++-- modules/PaypalStandard/module.json | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/Setting/Module.php b/app/Http/Requests/Setting/Module.php index 82e6108ef..940f8046e 100644 --- a/app/Http/Requests/Setting/Module.php +++ b/app/Http/Requests/Setting/Module.php @@ -29,8 +29,8 @@ class Module extends FormRequest if ($module->get('settings')) { foreach ($module->get('settings') as $field) { - if (isset($field['attributes']['required'])) { - $rules[$field['name']] = $field['attributes']['required']; + if (isset($field['rules'])) { + $rules[$field['name']] = $field['rules']; } } } diff --git a/modules/PaypalStandard/module.json b/modules/PaypalStandard/module.json index ce0827c1d..c633dbd9f 100644 --- a/modules/PaypalStandard/module.json +++ b/modules/PaypalStandard/module.json @@ -20,7 +20,8 @@ "icon": "fa fa-font", "attributes": { "required": "required" - } + }, + "rules": "required" }, { "type": "textGroup", @@ -29,7 +30,8 @@ "icon": "envelope", "attributes": { "required": "required" - } + }, + "rules": "required" }, { "type": "selectGroup", From 114b832a1f69018a6f838bcda42f92c89790e45e Mon Sep 17 00:00:00 2001 From: denisdulici Date: Sun, 22 Mar 2020 18:15:53 +0300 Subject: [PATCH 2/5] added sendgrid service --- config/services.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/services.php b/config/services.php index 2a1d616c7..f88a89335 100644 --- a/config/services.php +++ b/config/services.php @@ -30,4 +30,8 @@ return [ 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], + 'sendgrid' => [ + 'api_key' => env('SENDGRID_API_KEY'), + ], + ]; From 1852a76859b4a2eaceda179bc4ded6440004c7aa Mon Sep 17 00:00:00 2001 From: denisdulici Date: Sun, 22 Mar 2020 18:40:08 +0300 Subject: [PATCH 3/5] improved settings rules --- app/Http/Requests/Setting/Module.php | 14 +++++++++----- modules/PaypalStandard/module.json | 27 ++++++++++++++++++--------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/Http/Requests/Setting/Module.php b/app/Http/Requests/Setting/Module.php index 940f8046e..ea2908005 100644 --- a/app/Http/Requests/Setting/Module.php +++ b/app/Http/Requests/Setting/Module.php @@ -27,12 +27,16 @@ class Module extends FormRequest $module = module($this->request->get('module_alias')); - if ($module->get('settings')) { - foreach ($module->get('settings') as $field) { - if (isset($field['rules'])) { - $rules[$field['name']] = $field['rules']; - } + if (!$fields = $module->get('settings')) { + return $rules; + } + + foreach ($fields as $field) { + if (empty($field['rules'])) { + continue; } + + $rules[$field['name']] = $field['rules']; } return $rules; diff --git a/modules/PaypalStandard/module.json b/modules/PaypalStandard/module.json index c633dbd9f..fc7ed3410 100644 --- a/modules/PaypalStandard/module.json +++ b/modules/PaypalStandard/module.json @@ -21,7 +21,7 @@ "attributes": { "required": "required" }, - "rules": "required" + "rules": "required|string" }, { "type": "textGroup", @@ -31,7 +31,7 @@ "attributes": { "required": "required" }, - "rules": "required" + "rules": "required|email" }, { "type": "selectGroup", @@ -42,8 +42,11 @@ "live": "Live", "sandbox": "Sandbox" }, - "selected": null, - "attributes": {} + "selected": "live", + "attributes": { + "required": "required" + }, + "rules": "required|string" }, { "type": "selectGroup", @@ -54,8 +57,11 @@ "authorization": "Authorization", "sale": "Sale" }, - "selected": null, - "attributes": {} + "selected": "sale", + "attributes": { + "required": "required" + }, + "rules": "required|string" }, { "type": "radioGroup", @@ -63,7 +69,8 @@ "title": "paypal-standard::general.form.customer", "enable": "general.yes", "disable": "general.no", - "attributes": {} + "attributes": {}, + "rules": "required|integer" }, { "type": "radioGroup", @@ -71,14 +78,16 @@ "title": "paypal-standard::general.form.debug", "enable": "general.yes", "disable": "general.no", - "attributes": {} + "attributes": {}, + "rules": "required|integer" }, { "type": "textGroup", "name": "order", "title": "paypal-standard::general.form.order", "icon": "sort", - "attributes": {} + "attributes": {}, + "rules": "nullable|integer" } ] } From 8e4f28a8a7ae857855a761144f0c384fcce15389 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Mon, 23 Mar 2020 09:24:34 +0300 Subject: [PATCH 4/5] updated dingo api version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 49cf4b320..b3995c435 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "bkwld/cloner": "3.6.*", "consoletvs/charts": "6.5.*", "doctrine/dbal": "2.9.*", - "dingo/api": "3.0.0-rc3", + "dingo/api": "3.0.*", "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^1.0", "genealabs/laravel-model-caching": "0.8.*", From 59cc7b4fd196835f5800b3fcc29abdf3af6ea598 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Mon, 23 Mar 2020 20:02:00 +0300 Subject: [PATCH 5/5] added default account name --- app/Models/Banking/Transfer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Banking/Transfer.php b/app/Models/Banking/Transfer.php index 554875b9d..79cb83247 100644 --- a/app/Models/Banking/Transfer.php +++ b/app/Models/Banking/Transfer.php @@ -32,7 +32,7 @@ class Transfer extends Model public function expense_account() { - return $this->belongsTo('App\Models\Banking\Account', 'expense_transaction.account_id', 'id'); + return $this->belongsTo('App\Models\Banking\Account', 'expense_transaction.account_id', 'id')->withDefault(['name' => trans('general.na')]); } public function income_transaction() @@ -42,6 +42,6 @@ class Transfer extends Model public function income_account() { - return $this->belongsTo('App\Models\Banking\Account', 'income_transaction.account_id', 'id'); + return $this->belongsTo('App\Models\Banking\Account', 'income_transaction.account_id', 'id')->withDefault(['name' => trans('general.na')]); } }