From df5eb71cbb97e7c0fb5e3c32ea1e88d8930d9ffa Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Tue, 18 Dec 2018 12:55:19 +0300 Subject: [PATCH] Offline Payment re-factoring --- modules/OfflinePayment/Assets/.gitkeep | 0 modules/OfflinePayment/Config/.gitkeep | 0 modules/OfflinePayment/Config/config.php | 7 --- modules/OfflinePayment/Console/.gitkeep | 0 .../Database/Migrations/.gitkeep | 0 .../OfflinePayment/Database/Seeders/.gitkeep | 0 modules/OfflinePayment/Entities/.gitkeep | 0 modules/OfflinePayment/Events/.gitkeep | 0 .../OfflinePayment/Events/Handlers/.gitkeep | 0 .../OfflinePayment/Http/Controllers/.gitkeep | 0 .../Http/Controllers/OfflinePayment.php | 7 +-- .../Http/Controllers/Settings.php | 3 +- .../OfflinePayment/Http/Middleware/.gitkeep | 0 modules/OfflinePayment/Http/Requests/.gitkeep | 0 modules/OfflinePayment/Http/routes.php | 26 ++++++--- modules/OfflinePayment/Jobs/.gitkeep | 0 .../OfflinePaymentAdminMenu.php | 7 +-- .../OfflinePaymentGateway.php | 2 +- modules/OfflinePayment/Mail/.gitkeep | 0 modules/OfflinePayment/Providers/.gitkeep | 0 .../OfflinePaymentServiceProvider.php | 44 +++++---------- modules/OfflinePayment/Repositories/.gitkeep | 0 .../OfflinePayment/Resources/lang/.gitkeep | 0 .../Resources/lang/en-GB/general.php | 21 ++++++++ .../Resources/lang/en-GB/offlinepayment.php | 16 ------ .../OfflinePayment/Resources/views/.gitkeep | 0 .../Resources/views/confirm.blade.php | 2 +- .../Resources/views/edit.blade.php | 53 +++++++++++++------ .../Resources/views/link.blade.php | 3 +- .../Resources/views/show.blade.php | 3 +- modules/OfflinePayment/Tests/.gitkeep | 0 modules/OfflinePayment/module.json | 4 +- 32 files changed, 107 insertions(+), 91 deletions(-) delete mode 100644 modules/OfflinePayment/Assets/.gitkeep delete mode 100644 modules/OfflinePayment/Config/.gitkeep delete mode 100644 modules/OfflinePayment/Config/config.php delete mode 100644 modules/OfflinePayment/Console/.gitkeep delete mode 100644 modules/OfflinePayment/Database/Migrations/.gitkeep delete mode 100644 modules/OfflinePayment/Database/Seeders/.gitkeep delete mode 100644 modules/OfflinePayment/Entities/.gitkeep delete mode 100644 modules/OfflinePayment/Events/.gitkeep delete mode 100644 modules/OfflinePayment/Events/Handlers/.gitkeep delete mode 100644 modules/OfflinePayment/Http/Controllers/.gitkeep delete mode 100644 modules/OfflinePayment/Http/Middleware/.gitkeep delete mode 100644 modules/OfflinePayment/Http/Requests/.gitkeep delete mode 100644 modules/OfflinePayment/Jobs/.gitkeep rename modules/OfflinePayment/{Events/Handlers => Listeners}/OfflinePaymentAdminMenu.php (81%) rename modules/OfflinePayment/{Events/Handlers => Listeners}/OfflinePaymentGateway.php (86%) delete mode 100644 modules/OfflinePayment/Mail/.gitkeep delete mode 100644 modules/OfflinePayment/Providers/.gitkeep delete mode 100644 modules/OfflinePayment/Repositories/.gitkeep delete mode 100644 modules/OfflinePayment/Resources/lang/.gitkeep create mode 100644 modules/OfflinePayment/Resources/lang/en-GB/general.php delete mode 100644 modules/OfflinePayment/Resources/lang/en-GB/offlinepayment.php delete mode 100644 modules/OfflinePayment/Resources/views/.gitkeep delete mode 100644 modules/OfflinePayment/Tests/.gitkeep diff --git a/modules/OfflinePayment/Assets/.gitkeep b/modules/OfflinePayment/Assets/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Config/.gitkeep b/modules/OfflinePayment/Config/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Config/config.php b/modules/OfflinePayment/Config/config.php deleted file mode 100644 index f580eb589..000000000 --- a/modules/OfflinePayment/Config/config.php +++ /dev/null @@ -1,7 +0,0 @@ - 'OfflinePayment', - -]; diff --git a/modules/OfflinePayment/Console/.gitkeep b/modules/OfflinePayment/Console/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Database/Migrations/.gitkeep b/modules/OfflinePayment/Database/Migrations/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Database/Seeders/.gitkeep b/modules/OfflinePayment/Database/Seeders/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Entities/.gitkeep b/modules/OfflinePayment/Entities/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Events/.gitkeep b/modules/OfflinePayment/Events/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Events/Handlers/.gitkeep b/modules/OfflinePayment/Events/Handlers/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Http/Controllers/.gitkeep b/modules/OfflinePayment/Http/Controllers/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Http/Controllers/OfflinePayment.php b/modules/OfflinePayment/Http/Controllers/OfflinePayment.php index 61218ae71..4074a37d8 100644 --- a/modules/OfflinePayment/Http/Controllers/OfflinePayment.php +++ b/modules/OfflinePayment/Http/Controllers/OfflinePayment.php @@ -4,7 +4,6 @@ namespace Modules\OfflinePayment\Http\Controllers; use App\Events\InvoicePaid; -use Illuminate\Http\Response; use Illuminate\Routing\Controller; use Illuminate\Http\Request; @@ -16,11 +15,12 @@ use SignedUrl; class OfflinePayment extends Controller { + /** * Show the form for editing the specified resource. * @param Invoice * @param PaymentRequest - * @return Response + * @return JSON */ public function show(Invoice $invoice, PaymentRequest $request) { @@ -46,11 +46,12 @@ class OfflinePayment extends Controller 'html' => $html, ]); } + /** * Show the form for editing the specified resource. * @param $invoice * @param $request - * @return Response + * @return JSON */ public function link(Invoice $invoice, PaymentRequest $request) { diff --git a/modules/OfflinePayment/Http/Controllers/Settings.php b/modules/OfflinePayment/Http/Controllers/Settings.php index b0b14e110..9e5fca632 100644 --- a/modules/OfflinePayment/Http/Controllers/Settings.php +++ b/modules/OfflinePayment/Http/Controllers/Settings.php @@ -12,6 +12,7 @@ use Modules\OfflinePayment\Http\Requests\SettingDelete as DRequest; class Settings extends Controller { + /** * Show the form for editing the specified resource. * @@ -66,7 +67,7 @@ class Settings extends Controller Artisan::call('cache:clear'); - return redirect('apps/offlinepayment/settings'); + return redirect()->route('offlinepayment.edit'); } /** diff --git a/modules/OfflinePayment/Http/Middleware/.gitkeep b/modules/OfflinePayment/Http/Middleware/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Http/Requests/.gitkeep b/modules/OfflinePayment/Http/Requests/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Http/routes.php b/modules/OfflinePayment/Http/routes.php index c2c27f400..0dc0b97f7 100644 --- a/modules/OfflinePayment/Http/routes.php +++ b/modules/OfflinePayment/Http/routes.php @@ -1,18 +1,30 @@ ['web', 'auth', 'language', 'adminmenu', 'permission:read-admin-panel'], 'prefix' => 'apps/offlinepayment', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () { - Route::get('settings', 'Settings@edit'); - Route::post('settings', 'Settings@update'); - Route::post('settings/get', 'Settings@get'); - Route::post('settings/delete', 'Settings@delete'); +Route::group([ + 'middleware' => 'admin', + 'prefix' => 'apps/offlinepayment', + 'namespace' => 'Modules\OfflinePayment\Http\Controllers' +], function () { + Route::get('settings', 'Settings@edit')->name('offlinepayment.edit'); + Route::post('settings', 'Settings@update')->name('offlinepayment.update'); + Route::post('settings/get', 'Settings@get')->name('offlinepayment.get'); + Route::post('settings/delete', 'Settings@delete')->name('offlinepayment.delete'); }); -Route::group(['middleware' => ['web', 'auth', 'language', 'customermenu', 'permission:read-customer-panel'], 'prefix' => 'customers', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () { +Route::group([ + 'middleware' => ['web', 'auth', 'language', 'customermenu', 'permission:read-customer-panel'], + 'prefix' => 'customers', + 'namespace' => 'Modules\OfflinePayment\Http\Controllers' +], function () { Route::get('invoices/{invoice}/offlinepayment', 'OfflinePayment@show'); Route::post('invoices/{invoice}/offlinepayment/confirm', 'OfflinePayment@confirm'); }); -Route::group(['middleware' => ['web', 'language'], 'prefix' => 'links', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () { +Route::group([ + 'middleware' => ['web', 'language'], + 'prefix' => 'links', + 'namespace' => 'Modules\OfflinePayment\Http\Controllers' +], function () { Route::group(['middleware' => 'signed-url'], function () { Route::post('invoices/{invoice}/offlinepayment', 'OfflinePayment@link'); Route::post('invoices/{invoice}/offlinepayment/confirm', 'OfflinePayment@confirm'); diff --git a/modules/OfflinePayment/Jobs/.gitkeep b/modules/OfflinePayment/Jobs/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Events/Handlers/OfflinePaymentAdminMenu.php b/modules/OfflinePayment/Listeners/OfflinePaymentAdminMenu.php similarity index 81% rename from modules/OfflinePayment/Events/Handlers/OfflinePaymentAdminMenu.php rename to modules/OfflinePayment/Listeners/OfflinePaymentAdminMenu.php index 3ad2fb310..2aa3bcb6b 100644 --- a/modules/OfflinePayment/Events/Handlers/OfflinePaymentAdminMenu.php +++ b/modules/OfflinePayment/Listeners/OfflinePaymentAdminMenu.php @@ -1,12 +1,13 @@ menu->whereTitle(trans_choice('general.settings', 2)); - $item->url('apps/offlinepayment/settings', trans('offlinepayment::offlinepayment.offlinepayment'), 4, ['icon' => 'fa fa-angle-double-right']); + $item->url('apps/offlinepayment/settings', trans('offlinepayment::general.title'), 4, ['icon' => 'fa fa-angle-double-right']); } } } diff --git a/modules/OfflinePayment/Events/Handlers/OfflinePaymentGateway.php b/modules/OfflinePayment/Listeners/OfflinePaymentGateway.php similarity index 86% rename from modules/OfflinePayment/Events/Handlers/OfflinePaymentGateway.php rename to modules/OfflinePayment/Listeners/OfflinePaymentGateway.php index eaf12a187..2e03b8c46 100644 --- a/modules/OfflinePayment/Events/Handlers/OfflinePaymentGateway.php +++ b/modules/OfflinePayment/Listeners/OfflinePaymentGateway.php @@ -1,6 +1,6 @@ registerTranslations(); - $this->registerConfig(); $this->registerViews(); - $this->registerFactories(); + $this->registerMigrations(); - $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); - - $this->app['events']->listen(AdminMenuCreated::class, OfflinePaymentAdminMenu::class); - $this->app['events']->listen(PaymentGatewayListing::class, OfflinePaymentGateway::class); + $this->registerEvents(); } /** @@ -48,21 +43,6 @@ class OfflinePaymentServiceProvider extends ServiceProvider // } - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - __DIR__.'/../Config/config.php' => config_path('offlinepayment.php'), - ], 'config'); - $this->mergeConfigFrom( - __DIR__.'/../Config/config.php', 'offlinepayment' - ); - } - /** * Register views. * @@ -99,15 +79,15 @@ class OfflinePaymentServiceProvider extends ServiceProvider } } - /** - * Register an additional directory of factories. - * @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66 - */ - public function registerFactories() + public function registerMigrations() { - if (! app()->environment('production')) { - app(Factory::class)->load(__DIR__ . '/Database/factories'); - } + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + } + + public function registerEvents() + { + $this->app['events']->listen(AdminMenuCreated::class, OfflinePaymentAdminMenu::class); + $this->app['events']->listen(PaymentGatewayListing::class, OfflinePaymentGateway::class); } /** diff --git a/modules/OfflinePayment/Repositories/.gitkeep b/modules/OfflinePayment/Repositories/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Resources/lang/.gitkeep b/modules/OfflinePayment/Resources/lang/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Resources/lang/en-GB/general.php b/modules/OfflinePayment/Resources/lang/en-GB/general.php new file mode 100644 index 000000000..1a159e418 --- /dev/null +++ b/modules/OfflinePayment/Resources/lang/en-GB/general.php @@ -0,0 +1,21 @@ + 'Offline Payments', + + 'add_new' => 'Add New', + 'edit' => 'Edit: :method', + + 'form' => [ + 'code' => 'Code', + 'customer' => 'Show to Customer', + 'order' => 'Order' + ], + + 'payment_gateways' => 'Offline Payment Methods', + + 'confirm' => 'Confirm', + 'loading' => 'Loading', + +]; diff --git a/modules/OfflinePayment/Resources/lang/en-GB/offlinepayment.php b/modules/OfflinePayment/Resources/lang/en-GB/offlinepayment.php deleted file mode 100644 index 541a5c57c..000000000 --- a/modules/OfflinePayment/Resources/lang/en-GB/offlinepayment.php +++ /dev/null @@ -1,16 +0,0 @@ - 'Offline Payments', - 'add_new' => 'Add New', - 'edit' => 'Edit: :method', - 'code' => 'Code', - 'customer' => 'Show to Customer', - 'order' => 'Order', - 'payment_gateways' => 'Offline Payment Methods', - - 'confirm' => 'Confirm', - 'loading' => 'Loading', - -]; diff --git a/modules/OfflinePayment/Resources/views/.gitkeep b/modules/OfflinePayment/Resources/views/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/OfflinePayment/Resources/views/confirm.blade.php b/modules/OfflinePayment/Resources/views/confirm.blade.php index 7ab1f30bf..793869e38 100644 --- a/modules/OfflinePayment/Resources/views/confirm.blade.php +++ b/modules/OfflinePayment/Resources/views/confirm.blade.php @@ -4,4 +4,4 @@
{{ $gateway['description'] }}
-@endif \ No newline at end of file +@endif diff --git a/modules/OfflinePayment/Resources/views/edit.blade.php b/modules/OfflinePayment/Resources/views/edit.blade.php index c7dfd9be3..be5e0b6e2 100644 --- a/modules/OfflinePayment/Resources/views/edit.blade.php +++ b/modules/OfflinePayment/Resources/views/edit.blade.php @@ -1,29 +1,29 @@ @extends('layouts.admin') -@section('title', trans('offlinepayment::offlinepayment.offlinepayment')) +@section('title', trans('offlinepayment::general.title')) @section('content')
-

{{ trans('offlinepayment::offlinepayment.add_new') }}

+

{{ trans('offlinepayment::general.add_new') }}

- {!! Form::open(['url' => 'apps/offlinepayment/settings', 'files' => true, 'role' => 'form']) !!} + {!! Form::open(['route' => 'offlinepayment.update', 'files' => true, 'role' => 'form', 'class' => 'form-loading-button']) !!}
{{ Form::textGroup('name', trans('general.name'), 'id-card-o', ['required' => 'required'], null, 'col-md-12') }} - {{ Form::textGroup('code', trans('offlinepayment::offlinepayment.code'), 'key', ['required' => 'required'], null, 'col-md-12') }} + {{ Form::textGroup('code', trans('offlinepayment::general.form.code'), 'key', ['required' => 'required'], null, 'col-md-12') }} - {{ Form::radioGroup('customer', trans('offlinepayment::offlinepayment.customer'), '', ['required' => 'required'], 0, 'col-md-12') }} + {{ Form::radioGroup('customer', trans('offlinepayment::general.form.customer'), '', ['required' => 'required'], 0, 'col-md-12') }} - {{ Form::textGroup('order', trans('offlinepayment::offlinepayment.order'), 'sort', [], null, 'col-md-12') }} + {{ Form::textGroup('order', trans('offlinepayment::general.form.order'), 'sort', [], null, 'col-md-12') }} {{ Form::textareaGroup('description', trans('general.description')) }}
@@ -38,22 +38,25 @@
+
-

{{ trans('offlinepayment::offlinepayment.payment_gateways') }}

+

{{ trans('offlinepayment::general.payment_gateways') }}

+
+
- - + + @@ -86,13 +89,14 @@ @push('stylesheet') @endpush @@ -115,22 +123,25 @@
{{ trans('general.name') }}{{ trans('offlinepayment::offlinepayment.code') }}{{ trans('offlinepayment::offlinepayment.order') }}{{ trans('offlinepayment::general.form.code') }}{{ trans('offlinepayment::general.form.order') }} {{ trans('general.actions') }}