Skip to content

Commit dea7391

Browse files
committed
applied new route macros and structure
1 parent ac7788a commit dea7391

File tree

6 files changed

+40
-87
lines changed

6 files changed

+40
-87
lines changed

Http/Controllers/Payment.php

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use App\Http\Requests\Portal\InvoicePayment as PaymentRequest;
88
use App\Models\Document\Document;
99
use Illuminate\Http\Request;
10-
use Illuminate\Support\Facades\URL;
1110

1211
class Payment extends PaymentController
1312
{
@@ -29,34 +28,9 @@ public function show(Document $invoice, PaymentRequest $request)
2928
}
3029
}
3130

32-
$html = view('offline-payments::show', compact('setting', 'invoice'))->render();
31+
$confirm_url = $this->getConfirmUrl($invoice);
3332

34-
return response()->json([
35-
'code' => $setting['code'],
36-
'name' => $setting['name'],
37-
'description' => $setting['description'],
38-
'redirect' => false,
39-
'html' => $html,
40-
]);
41-
}
42-
43-
public function signed(Document $invoice, PaymentRequest $request)
44-
{
45-
$setting = [];
46-
47-
$payment_methods = json_decode(setting('offline-payments.methods'), true);
48-
49-
foreach ($payment_methods as $payment_method) {
50-
if ($payment_method['code'] == $request['payment_method']) {
51-
$setting = $payment_method;
52-
53-
break;
54-
}
55-
}
56-
57-
$confirm_url = URL::signedRoute('signed.invoices.offline-payments.confirm', [$invoice->id, 'company_id' => session('company_id')]);
58-
59-
$html = view('offline-payments::signed', compact('setting', 'invoice', 'confirm_url'))->render();
33+
$html = view('offline-payments::show', compact('setting', 'invoice', 'confirm_url'))->render();
6034

6135
return response()->json([
6236
'code' => $setting['code'],

Resources/views/show.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div class="buttons">
1414
<div class="pull-right">
1515
{!! Form::open([
16-
'url' => route("portal.invoices.offline-payments.confirm", $invoice->id),
16+
'url' => $confirm_url,
1717
'id' => 'redirect-form',
1818
'role' => 'form',
1919
'autocomplete' => "off",
@@ -24,7 +24,7 @@
2424
</button>
2525
{!! Form::hidden('payment_method', $setting['code']) !!}
2626
{!! Form::hidden('type', 'income') !!}
27-
27+
2828
{!! Form::close() !!}
2929
</div>
3030
</div>

Resources/views/signed.blade.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

Routes/admin.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?php
22

3-
Route::group([
4-
'prefix' => '{company_id}',
5-
'middleware' => 'admin',
6-
'namespace' => 'Modules\OfflinePayments\Http\Controllers'
7-
], function () {
8-
Route::group(['prefix' => 'offline-payments', 'as' => 'offline-payments.'], function () {
9-
Route::group(['prefix' => 'settings', 'as' => 'settings.'], function () {
10-
Route::get('/', 'Settings@edit')->name('edit');
11-
Route::post('/', 'Settings@update')->name('update');
12-
Route::post('get', 'Settings@get')->name('get');
13-
Route::delete('delete', 'Settings@destroy')->name('delete');
14-
});
3+
use Illuminate\Support\Facades\Route;
4+
5+
/**
6+
* 'admin' middleware and 'offline-payments' prefix applied to all routes (including names)
7+
*
8+
* @see \App\Providers\Route::register
9+
*/
10+
11+
Route::admin('offline-payments', function () {
12+
Route::group(['prefix' => 'settings', 'as' => 'settings.'], function () {
13+
Route::get('/', 'Settings@edit')->name('edit');
14+
Route::post('/', 'Settings@update')->name('update');
15+
Route::post('get', 'Settings@get')->name('get');
16+
Route::delete('delete', 'Settings@destroy')->name('delete');
1517
});
1618
});

Routes/portal.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
22

3-
Route::group([
4-
'prefix' => '{company_id}/portal',
5-
'middleware' => 'portal',
6-
'namespace' => 'Modules\OfflinePayments\Http\Controllers'
7-
], function () {
8-
Route::get('invoices/{invoice}/offline-payments', 'Payment@show')->name('portal.invoices.offline-payments.show');
9-
Route::post('invoices/{invoice}/offline-payments/confirm', 'Payment@confirm')->name('portal.invoices.offline-payments.confirm');
3+
use Illuminate\Support\Facades\Route;
4+
5+
/**
6+
* 'portal' middleware and 'portal/offline-payments' prefix applied to all routes (including names)
7+
*
8+
* @see \App\Providers\Route::register
9+
*/
10+
11+
Route::portal('offline-payments', function () {
12+
Route::get('invoices/{invoice}', 'Payment@show')->name('invoices.show');
13+
Route::post('invoices/{invoice}/confirm', 'Payment@confirm')->name('invoices.confirm');
1014
});

Routes/signed.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
22

3-
Route::group([
4-
'prefix' => '{company_id}/signed',
5-
'middleware' => 'signed',
6-
'namespace' => 'Modules\OfflinePayments\Http\Controllers'
7-
], function () {
8-
Route::get('invoices/{invoice}/offline-payments', 'Payment@signed')->name('signed.invoices.offline-payments.show');
9-
Route::post('invoices/{invoice}/offline-payments/confirm', 'Payment@confirm')->name('signed.invoices.offline-payments.confirm');
3+
use Illuminate\Support\Facades\Route;
4+
5+
/**
6+
* 'signed' middleware and 'signed/offline-payments' prefix applied to all routes (including names)
7+
*
8+
* @see \App\Providers\Route::register
9+
*/
10+
11+
Route::signed('offline-payments', function () {
12+
Route::get('invoices/{invoice}', 'Payment@show')->name('invoices.show');
13+
Route::post('invoices/{invoice}/confirm', 'Payment@confirm')->name('invoices.confirm');
1014
});

0 commit comments

Comments
 (0)