From 55e644f214729ece7e6980afd08f3e7a32017639 Mon Sep 17 00:00:00 2001 From: karneaud Date: Wed, 3 Jul 2024 20:56:58 -0400 Subject: [PATCH 1/3] do not need these files --- app/Http/ViewComposers/RotessaComposer.php | 16 ----------- app/Providers/RotessaServiceProvider.php | 31 ---------------------- 2 files changed, 47 deletions(-) delete mode 100644 app/Http/ViewComposers/RotessaComposer.php delete mode 100644 app/Providers/RotessaServiceProvider.php diff --git a/app/Http/ViewComposers/RotessaComposer.php b/app/Http/ViewComposers/RotessaComposer.php deleted file mode 100644 index 493d955267b4..000000000000 --- a/app/Http/ViewComposers/RotessaComposer.php +++ /dev/null @@ -1,16 +0,0 @@ -with('states', $states); -}); - -// CAProvinces View Composer -View::composer(['*.rotessa.components.address','*.rotessa.components.banks.CA.bank','*.rotessa.components.dropdowns.country.CA'], function ($view) { - $provinces = CAProvinces::get(); - $view->with('provinces', $provinces); -}); \ No newline at end of file diff --git a/app/Providers/RotessaServiceProvider.php b/app/Providers/RotessaServiceProvider.php deleted file mode 100644 index 4f01a045dbf3..000000000000 --- a/app/Providers/RotessaServiceProvider.php +++ /dev/null @@ -1,31 +0,0 @@ -registerComponent(); - } - - /** - * Register views. - */ - public function registerComponent(): void - { - Blade::componentNamespace('App\\Http\\ViewComposers\\Components', $this->moduleNameLower); - } -} From 109e2a46d82434988bd65557c44eddc632cf7287 Mon Sep 17 00:00:00 2001 From: karneaud Date: Wed, 3 Jul 2024 20:58:20 -0400 Subject: [PATCH 2/3] removed this file --- .../Components/RotessaComponents.php | 123 ------------------ 1 file changed, 123 deletions(-) delete mode 100644 app/Http/ViewComposers/Components/RotessaComponents.php diff --git a/app/Http/ViewComposers/Components/RotessaComponents.php b/app/Http/ViewComposers/Components/RotessaComponents.php deleted file mode 100644 index b984d0bb2339..000000000000 --- a/app/Http/ViewComposers/Components/RotessaComponents.php +++ /dev/null @@ -1,123 +0,0 @@ -client->contacts->firstWhere('is_primary', 1)->toArray())->merge([ - 'home_phone' =>$contact->client->phone, - 'custom_identifier' => $contact->client->number, - 'name' =>$contact->client->name, - 'id' => null - ] )->all(); - - $this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields) ); - } - - private $fields = [ - 'name', - 'email', - 'home_phone', - 'phone', - 'custom_identifier', - 'customer_type' , - 'id' - ]; - - private $defaults = [ - 'customer_type' => "Business", - 'customer_identifier' => null, - 'id' => null - ]; - - public function render() - { - return render('gateways.rotessa.components.contact', array_merge($this->defaults, $this->attributes->getAttributes() ) ); - } -} - -// Address Component -class AddressComponent extends Component -{ - private $fields = [ - 'address_1', - 'address_2', - 'city', - 'postal_code', - 'province_code', - 'country' - ]; - - private $defaults = [ - 'country' => 'US' - ]; - - public array $address; - - public function __construct(array $address) { - $this->address = $address; - if(strlen($this->address['state']) > 2 ) { - $this->address['state'] = $this->address['country'] == 'US' ? array_search($this->address['state'], USStates::$states) : CAProvinces::getAbbreviation($this->address['state']); - } - - $this->attributes = $this->newAttributeBag( - Arr::only(Arr::mapWithKeys($this->address, function ($item, $key) { - return in_array($key, ['address1','address2','state'])?[ (['address1'=>'address_1','address2'=>'address_2','state'=>'province_code'])[$key] => $item ] :[ $key => $item ]; - }), - $this->fields) ); - } - - - public function render() - { - return render('gateways.rotessa.components.address',array_merge( $this->defaults, $this->attributes->getAttributes() ) ); - } -} - -// AmericanBankInfo Component -class AccountComponent extends Component -{ - private $fields = [ - 'bank_account_type', - 'routing_number', - 'institution_number', - 'transit_number', - 'bank_name', - 'country', - 'account_number' - ]; - - private $defaults = [ - 'bank_account_type' => null, - 'routing_number' => null, - 'institution_number' => null, - 'transit_number' => null, - 'bank_name' => ' ', - 'account_number' => null, - 'country' => 'US', - "authorization_type" => 'Online' - ]; - - public array $account; - - public function __construct(array $account) { - $this->account = $account; - $this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields) ); - } - - public function render() - { - return render('gateways.rotessa.components.account', array_merge($this->attributes->getAttributes(), $this->defaults) ); - } -} From 65aafc31f9433b29c2b95248a175ed098a93d01c Mon Sep 17 00:00:00 2001 From: karneaud Date: Wed, 3 Jul 2024 20:58:51 -0400 Subject: [PATCH 3/3] refactor compser components for rotessa --- .../Components/Rotessa/AccountComponent.php | 47 ++++++++++++++++++ .../Components/Rotessa/AddressComponent.php | 48 +++++++++++++++++++ .../Components/Rotessa/ContactComponent.php | 48 +++++++++++++++++++ app/Http/ViewComposers/RotessaComposer.php | 16 +++++++ app/Providers/ComposerServiceProvider.php | 17 +++++-- app/Providers/RotessaServiceProvider.php | 31 ++++++++++++ 6 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 app/Http/ViewComposers/Components/Rotessa/AccountComponent.php create mode 100644 app/Http/ViewComposers/Components/Rotessa/AddressComponent.php create mode 100644 app/Http/ViewComposers/Components/Rotessa/ContactComponent.php create mode 100644 app/Http/ViewComposers/RotessaComposer.php create mode 100644 app/Providers/RotessaServiceProvider.php diff --git a/app/Http/ViewComposers/Components/Rotessa/AccountComponent.php b/app/Http/ViewComposers/Components/Rotessa/AccountComponent.php new file mode 100644 index 000000000000..46e44dc330d1 --- /dev/null +++ b/app/Http/ViewComposers/Components/Rotessa/AccountComponent.php @@ -0,0 +1,47 @@ + null, + 'routing_number' => null, + 'institution_number' => null, + 'transit_number' => null, + 'bank_name' => ' ', + 'account_number' => null, + 'country' => 'US', + "authorization_type" => 'Online' + ]; + + public array $account; + + public function __construct(array $account) { + $this->account = $account; + $this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields) ); + } + + public function render() + { + return render('gateways.rotessa.components.account', array_merge($this->attributes->getAttributes(), $this->defaults) ); + } +} diff --git a/app/Http/ViewComposers/Components/Rotessa/AddressComponent.php b/app/Http/ViewComposers/Components/Rotessa/AddressComponent.php new file mode 100644 index 000000000000..5b5afc1599e5 --- /dev/null +++ b/app/Http/ViewComposers/Components/Rotessa/AddressComponent.php @@ -0,0 +1,48 @@ + 'US' + ]; + + public array $address; + + public function __construct(array $address) { + $this->address = $address; + if(strlen($this->address['state']) > 2 ) { + $this->address['state'] = $this->address['country'] == 'US' ? array_search($this->address['state'], USStates::$states) : CAProvinces::getAbbreviation($this->address['state']); + } + + $this->attributes = $this->newAttributeBag( + Arr::only(Arr::mapWithKeys($this->address, function ($item, $key) { + return in_array($key, ['address1','address2','state'])?[ (['address1'=>'address_1','address2'=>'address_2','state'=>'province_code'])[$key] => $item ] :[ $key => $item ]; + }), + $this->fields) ); + } + + + public function render() + { + return render('gateways.rotessa.components.address',array_merge( $this->defaults, $this->attributes->getAttributes() ) ); + } +} diff --git a/app/Http/ViewComposers/Components/Rotessa/ContactComponent.php b/app/Http/ViewComposers/Components/Rotessa/ContactComponent.php new file mode 100644 index 000000000000..b8c001b750e0 --- /dev/null +++ b/app/Http/ViewComposers/Components/Rotessa/ContactComponent.php @@ -0,0 +1,48 @@ +client->contacts->firstWhere('is_primary', 1)->toArray())->merge([ + 'home_phone' =>$contact->client->phone, + 'custom_identifier' => $contact->client->number, + 'name' =>$contact->client->name, + 'id' => null + ] )->all(); + + $this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields) ); + } + + private $fields = [ + 'name', + 'email', + 'home_phone', + 'phone', + 'custom_identifier', + 'customer_type' , + 'id' + ]; + + private $defaults = [ + 'customer_type' => "Business", + 'customer_identifier' => null, + 'id' => null + ]; + + public function render() + { + return render('gateways.rotessa.components.contact', array_merge($this->defaults, $this->attributes->getAttributes() ) ); + } +} diff --git a/app/Http/ViewComposers/RotessaComposer.php b/app/Http/ViewComposers/RotessaComposer.php new file mode 100644 index 000000000000..493d955267b4 --- /dev/null +++ b/app/Http/ViewComposers/RotessaComposer.php @@ -0,0 +1,16 @@ +with('states', $states); +}); + +// CAProvinces View Composer +View::composer(['*.rotessa.components.address','*.rotessa.components.banks.CA.bank','*.rotessa.components.dropdowns.country.CA'], function ($view) { + $provinces = CAProvinces::get(); + $view->with('provinces', $provinces); +}); \ No newline at end of file diff --git a/app/Providers/ComposerServiceProvider.php b/app/Providers/ComposerServiceProvider.php index 300d88f87768..b567dee2d302 100644 --- a/app/Providers/ComposerServiceProvider.php +++ b/app/Providers/ComposerServiceProvider.php @@ -14,6 +14,8 @@ namespace App\Providers; use App\Http\ViewComposers\PortalComposer; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Blade; +use App\DataProviders\CAProvinces; +use App\DataProviders\USStates; class ComposerServiceProvider extends ServiceProvider { @@ -25,9 +27,18 @@ class ComposerServiceProvider extends ServiceProvider public function boot() { view()->composer('portal.*', PortalComposer::class); - include_once app_path('Http/ViewComposers/RotessaComposer.php'); - include_once app_path("Http/ViewComposers/Components/RotessaComponents.php"); - Blade::componentNamespace('App\\Http\\ViewComposers\\Components', 'rotessa'); + view()->composer(['*.rotessa.components.address','*.rotessa.components.banks.US.bank','*.rotessa.components.dropdowns.country.US'], function ($view) { + $states = USStates::get(); + $view->with('states', $states); + }); + + // CAProvinces View Composer + view()->composer(['*.rotessa.components.address','*.rotessa.components.banks.CA.bank','*.rotessa.components.dropdowns.country.CA'], function ($view) { + $provinces = CAProvinces::get(); + $view->with('provinces', $provinces); + }); + + Blade::componentNamespace('App\\Http\\ViewComposers\\Components\\Rotessa', 'rotessa'); } /** diff --git a/app/Providers/RotessaServiceProvider.php b/app/Providers/RotessaServiceProvider.php new file mode 100644 index 000000000000..284bca9c708f --- /dev/null +++ b/app/Providers/RotessaServiceProvider.php @@ -0,0 +1,31 @@ +registerComponent(); + } + + /** + * Register views. + */ + public function registerComponent(): void + { + Blade::componentNamespace('App\\Http\\ViewComposers\\Components\\Rotessa', $this->moduleNameLower); + } +}