Skip to content

Commit cc48e36

Browse files
committed
- Removed javaabu helpers requirement
1 parent fcfd822 commit cc48e36

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^8.2",
20-
"laravel/framework": "^12.0",
21-
"javaabu/helpers": "^1.60"
20+
"laravel/framework": "^12.0"
2221
},
2322
"require-dev": {
2423
"mockery/mockery": "^1.6.10",

src/Foundation/Exceptions/Handler.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Auth\AuthenticationException;
66
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
77
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
8+
use Illuminate\Support\Facades\Request;
89

910
class Handler extends ExceptionHandler
1011
{
@@ -31,7 +32,7 @@ protected function getGuestRedirectPath(AuthenticationException $exception)
3132

3233
protected function getHttpExceptionView(HttpExceptionInterface $e)
3334
{
34-
if (current_portal() == 'admin') {
35+
if ($this->isAdminPortal()) {
3536
return parent::getHttpExceptionView($e);
3637
}
3738

@@ -49,4 +50,40 @@ protected function getHttpExceptionView(HttpExceptionInterface $e)
4950

5051
return parent::getHttpExceptionView($e);
5152
}
53+
54+
protected function isAdminPortal(): bool
55+
{
56+
$host = Request::getHost();
57+
58+
// get the main url
59+
$parse = parse_url(config('app.url'));
60+
$primary_domain = str_ireplace('www.', '', $parse['host']);
61+
62+
// get the admin domain
63+
$admin_domain = config('app.admin_domain');
64+
65+
if ($primary_domain != $admin_domain) {
66+
if ($host == $admin_domain) {
67+
return true;
68+
}
69+
} elseif ($admin_prefix = config('app.admin_prefix')) {
70+
// Get the current URL
71+
$url = Request::url();
72+
73+
// Parse the URL
74+
$parsed_url = parse_url($url);
75+
76+
// Get the path from the parsed URL
77+
$path = $parsed_url['path'] ?? '';
78+
79+
// Get the first part of the path
80+
$first_part = trim(explode('/', $path)[1] ?? '', '/');
81+
82+
if ($first_part == $admin_prefix) {
83+
return true;
84+
}
85+
}
86+
87+
return false;
88+
}
5289
}

0 commit comments

Comments
 (0)