Skip to content

Commit

Permalink
Offline Payment re-factoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Dec 18, 2018
1 parent 456335e commit df5eb71
Show file tree
Hide file tree
Showing 32 changed files with 107 additions and 91 deletions.
Empty file.
Empty file.
7 changes: 0 additions & 7 deletions modules/OfflinePayment/Config/config.php

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
7 changes: 4 additions & 3 deletions modules/OfflinePayment/Http/Controllers/OfflinePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Events\InvoicePaid;

use Illuminate\Http\Response;
use Illuminate\Routing\Controller;

use Illuminate\Http\Request;
Expand All @@ -16,11 +15,12 @@

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)
{
Expand All @@ -46,11 +46,12 @@ public function show(Invoice $invoice, PaymentRequest $request)
'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)
{
Expand Down
3 changes: 2 additions & 1 deletion modules/OfflinePayment/Http/Controllers/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class Settings extends Controller
{

/**
* Show the form for editing the specified resource.
*
Expand Down Expand Up @@ -66,7 +67,7 @@ public function update(Request $request)

Artisan::call('cache:clear');

return redirect('apps/offlinepayment/settings');
return redirect()->route('offlinepayment.edit');
}

/**
Expand Down
Empty file.
Empty file.
26 changes: 19 additions & 7 deletions modules/OfflinePayment/Http/routes.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
<?php

Route::group(['middleware' => ['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');
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace Modules\OfflinePayment\Events\Handlers;
namespace Modules\OfflinePayment\Listeners;

use App\Events\AdminMenuCreated;
use Auth;
use App\Events\AdminMenuCreated;

class OfflinePaymentAdminMenu
{

/**
* Handle the event.
*
Expand All @@ -22,7 +23,7 @@ public function handle(AdminMenuCreated $event)
// Add child to existing item
$item = $event->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']);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Modules\OfflinePayment\Events\Handlers;
namespace Modules\OfflinePayment\Listeners;

use App\Events\PaymentGatewayListing;

Expand Down
Empty file.
Empty file.
44 changes: 12 additions & 32 deletions modules/OfflinePayment/Providers/OfflinePaymentServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Modules\OfflinePayment\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;

use App\Events\AdminMenuCreated;
use Modules\OfflinePayment\Events\Handlers\OfflinePaymentAdminMenu;
use Modules\OfflinePayment\Listeners\OfflinePaymentAdminMenu;

use App\Events\PaymentGatewayListing;
use Modules\OfflinePayment\Events\Handlers\OfflinePaymentGateway;
use Modules\OfflinePayment\Listeners\OfflinePaymentGateway;

class OfflinePaymentServiceProvider extends ServiceProvider
{
Expand All @@ -28,14 +27,10 @@ class OfflinePaymentServiceProvider extends ServiceProvider
public function boot()
{
$this->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();
}

/**
Expand All @@ -48,21 +43,6 @@ public function register()
//
}

/**
* 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.
*
Expand Down Expand Up @@ -99,15 +79,15 @@ public function registerTranslations()
}
}

/**
* 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);
}

/**
Expand Down
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions modules/OfflinePayment/Resources/lang/en-GB/general.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

return [

'title' => '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',

];
16 changes: 0 additions & 16 deletions modules/OfflinePayment/Resources/lang/en-GB/offlinepayment.php

This file was deleted.

Empty file.
2 changes: 1 addition & 1 deletion modules/OfflinePayment/Resources/views/confirm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<div class="well well-sm">
{{ $gateway['description'] }}
</div>
@endif
@endif

0 comments on commit df5eb71

Please sign in to comment.