Skip to content

Commit 502e451

Browse files
committed
Adding better redirect for accessing internet
1 parent 7058c79 commit 502e451

File tree

5 files changed

+62
-32
lines changed

5 files changed

+62
-32
lines changed

Classes/Subscription.php

+14-3
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@ public function processData($data = [])
9393

9494
public function getSubscriber($data)
9595
{
96+
9697
if (isset($data['username']) && $data['username'] != '') {
9798
$subscriber = Subscriber::where(['username' => $data['username']])->first();
9899
if ($subscriber) {
99100
return $subscriber;
100101
}
101102
} else if (isset($data['mac']) && $data['mac'] != '') {
102103
$mac_address = MacAddress::where(['mac' => $data['mac']])->first();
103-
104+
104105
if ($mac_address) {
105106
$subscriber = Subscriber::where(['id' => $mac_address->subscriber_id])->first();
106107
if ($subscriber) {
@@ -131,13 +132,17 @@ public function saveSubcriber($data)
131132
$data['subscriber_id'] = $subscriber->id;
132133
$data['partner_id'] = $subscriber->partner_id;
133134
}
134-
135+
136+
135137
if (!isset($data['partner_id'])) {
136138
$partner = $this->addPartner($data);
139+
print_r($partner); exit;
137140
$data['partner_id'] = $partner->id;
138141
}
139142

140143
$item_subscriber = Subscriber::where(['partner_id' => $data['partner_id']])->first();
144+
145+
print_r($item_subscriber); exit;
141146
if (!$item_subscriber) {
142147
$item_subscriber = Subscriber::updateOrCreate([
143148
'username' => $username,
@@ -155,15 +160,21 @@ public function saveSubcriber($data)
155160
}
156161

157162
$mac_address = MacAddress::where(['subscriber_id' => $item_subscriber->id])->first();
163+
164+
158165
if (!$mac_address) {
159166
$mac_address = MacAddress::updateOrCreate([
160167
'subscriber_id' => $item_subscriber->id,
161168
'mac' => $data['mac'],
162169
]);
163170
}
164-
171+
165172
$invoice = $this->buyPackage($data['package_id'], $item_subscriber->id);
166173

174+
$data['invoice_id'] =$invoice->id;
175+
176+
$request->session()->put('subscription_data', $data);
177+
167178
return $invoice;
168179
}
169180

Entities/Data/LanguageTranslation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public function data(Datasetter $datasetter)
325325
$datasetter->add_data('core', 'language_translation', 'slug', [
326326
"slug" => "isp-access-mikrotik-login-wait",
327327
"language_id" => $language_id,
328-
"phrase" => "Please Wait...",
328+
"phrase" => "Please Wait for the system to open internet access automatically or Click the button below.",
329329
]);
330330

331331
$datasetter->add_data('core', 'language_translation', 'slug', [

Http/Controllers/SubscriptionController.php

+20-9
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public function profile(Request $request)
7979
$current_package = $subscription->getCurrentPackage($subscriber->id);
8080
}
8181

82-
$data = [
82+
$result = [
83+
'mac' => $data['mac'] ?? '',
8384
'return_url' => base64_encode(url(route('isp_access_thankyou'))),
8485
'profile_return_url' => base64_encode(url(route('isp_profile'))),
8586
'subscriber' => $subscriber,
@@ -93,14 +94,23 @@ public function profile(Request $request)
9394
];
9495

9596
$currency = new Currency();
96-
$data['currency'] = $currency->getDefaultCurrency();
97+
$result['currency'] = $currency->getDefaultCurrency();
98+
99+
if (isset($data['mac']) && $data['mac'] != '' && count($user_packages) > 0) {
100+
return redirect()
101+
->route('isp_access_mikrotik_login')
102+
->header('pragma', 'no-cache')
103+
->header('Cache-Control', 'no-store,no-cache, must-revalidate, post-check=0, pre-check=0');
104+
} else {
105+
return response()
106+
->view('isp::access-dashboard', $result)
107+
->header('pragma', 'no-cache')
108+
->header('Cache-Control', 'no-store,no-cache, must-revalidate, post-check=0, pre-check=0');
109+
110+
}
97111

98-
return response()
99-
->view('isp::access-dashboard', $data)
100-
->header('pragma', 'no-cache')
101-
->header('Cache-Control', 'no-store,no-cache, must-revalidate, post-check=0, pre-check=0');
102112
}
103-
113+
104114
public function autosubscribe(Request $request)
105115
{
106116

@@ -133,6 +143,7 @@ public function buyPackage(Request $request, $id)
133143
$data['currency'] = $currency->getDefaultCurrency();
134144

135145
$subscriber = $subscription->getSubscriber($data);
146+
136147
$invoice = $subscription->buyPackage($id, $subscriber->id);
137148

138149
if ($invoice->status == 'paid') {
@@ -363,13 +374,13 @@ public function mikrotiklogin(Request $request)
363374
$subscriber = $subscription->getSubscriber($data);
364375
$subscriber_login = SubscriberLogin::where('mac', $data['mac'])->first();
365376

366-
$data = [
377+
$result = [
367378
'subscriber' => $subscriber,
368379
'subscriber_login' => $subscriber_login,
369380
];
370381

371382
return response()
372-
->view('isp::access-mikrotik-login', $data, 200)
383+
->view('isp::access-mikrotik-login', $result, 200)
373384
->header('pragma', 'no-cache')
374385
->header('Cache-Control', 'no-store,no-cache, must-revalidate, post-check=0, pre-check=0');
375386
}

Resources/views/access-dashboard.blade.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ class="font-sm">{{ ___('isp-access-dashboard-account-balance') }}:</small><br>
295295
</span>
296296
</div>
297297
<div class="flex-auto text-center">
298-
<small class="font-sm">{{ ___('isp-access-dashboard-account-unpaid') }}:</small><br>
298+
<small
299+
class="font-sm">{{ ___('isp-access-dashboard-account-unpaid') }}:</small><br>
299300
{{ $invoices->count() }}
300301
</div>
301302
</div>
@@ -328,7 +329,8 @@ class=" shadow-xl rounded-md bg-gradient-to-br from-pink-500 via-red-900 to-pink
328329
</h4>
329330
</div>
330331
<div class="flex-auto text-right pr-4">
331-
<a href="{{ url(route('isp_access_buypackage', ['id' => $featured_package->id])) }}"
332+
<a @if (!$partner) href="{{ url(route('isp_access_buyform', ['package_id' => $featured_package->id, 'return_url' => $return_url])) }}"
333+
@else href="{{ url(route('isp_access_buypackage', ['id' => $featured_package->id, 'return_url' => $return_url])) }}" @endif
332334
class="bg-yellow-300 hover:bg-yellow-200 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
333335
{{ ___('isp-access-dashboard-buy-button') }}
334336
</a>
@@ -489,7 +491,6 @@ class="ml-2 inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs
489491
@if (!$partner) href="{{ url(route('isp_access_buyform', ['package_id' => $package->id, 'return_url' => $return_url])) }}"
490492
@else href="{{ url(route('isp_access_buypackage', ['id' => $package->id, 'return_url' => $return_url])) }}" @endif
491493
class="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs leading-tight uppercase rounded shadow-md hover:bg-blue-700 hover:shadow-lg focus:bg-blue-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out">
492-
Buy
493494
{{ ___('isp-access-dashboard-package-button') }}
494495
</a>
495496
</div>
@@ -502,7 +503,7 @@ class="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs leadi
502503
</div>
503504
</div>
504505
</section>
505-
506+
506507
<div class="relative overflow-hidden mb-8">
507508
<div class="overflow-hidden px-3 py-10 flex justify-center">
508509
<div class="w-full max-w-xs login-card">

Resources/views/access-mikrotik-login.blade.php

+22-15
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
<div class="bg-white mb-4">
1616

17-
18-
1917
<div class="text-center text-green-400">
2018
<p class="pt-4">
2119
{{ ___('isp-access-mikrotik-login-wait') }}
@@ -27,20 +25,29 @@
2725
</div>
2826

2927
@if ($subscriber_login)
30-
<form id="mikrotik_login" name="login" action="{{ $subscriber_login->link_login }}"
31-
method="post">
32-
<input type="hidden" name="username" value="{{ $subscriber->username }}">
33-
<input type="hidden" name="password" value="{{ $subscriber->password }}">
34-
<input type="hidden" name="domain" value="">
35-
<input type="hidden" name="dst" value="{{ $subscriber_login->link_orig_esc }}">
36-
37-
<p style="text-align:center;" class="p-1">
38-
<button id='register' type="submit" name="view" value="register"
28+
@if ($subscriber_login->link_login)
29+
<form id="mikrotik_login" name="login" action="{{ $subscriber_login->link_login }}"
30+
method="post">
31+
<input type="hidden" name="username" value="{{ $subscriber->username }}">
32+
<input type="hidden" name="password" value="{{ $subscriber->password }}">
33+
<input type="hidden" name="domain" value="">
34+
<input type="hidden" name="dst" value="{{ $subscriber_login->link_orig_esc }}">
35+
36+
<p style="text-align:center;" class="p-1">
37+
<button id='register' type="submit" name="view" value="register"
38+
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
39+
{{ ___('isp-access-mikrotik-login-button') }}
40+
</button>
41+
</p>
42+
</form>
43+
@else
44+
<div class="text-center text-red-400">
45+
<a href="https://www.google.com"
3946
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
4047
{{ ___('isp-access-mikrotik-login-button') }}
41-
</button>
42-
</p>
43-
</form>
48+
</a>
49+
</div>
50+
@endif
4451
@endif
4552

4653
</div>
@@ -58,7 +65,7 @@ class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focu
5865
<div class="w-full max-w-xs login-card">
5966

6067
<p class="text-center text-gray-500 text-xs">
61-
&copy;2022 - {{ date('Y') }}. {{ ___('isp-copy-right') }}
68+
&copy;2022 - {{ date('Y') }}. {{ ___('isp-copy-right') }}
6269
</p>
6370
</div>
6471
</div>

0 commit comments

Comments
 (0)