1 | <?php |
||||
2 | |||||
3 | namespace App\Services; |
||||
4 | |||||
5 | use Illuminate\Support\Facades\URL; |
||||
6 | |||||
7 | class WhichPortal |
||||
8 | { |
||||
9 | |||||
10 | public function home() |
||||
11 | 27 | { |
|||
12 | if ($this->isAdminPortal()) { |
||||
13 | 27 | return 'admin'; |
|||
14 | } elseif ($this->isManagerPortal()) { |
||||
15 | return route('manager.home'); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
16 | 32 | } |
|||
17 | return route('home'); |
||||
18 | 32 | } |
|||
19 | 32 | ||||
20 | public function isApplicantPortal() |
||||
21 | { |
||||
22 | 34 | return !$this->isManagerPortal() && !$this->isHrPortal() && !$this->isAdminPortal(); |
|||
23 | } |
||||
24 | 34 | ||||
25 | 34 | public function isManagerPortal() |
|||
26 | 34 | { |
|||
27 | 34 | $url = URL::current(); |
|||
28 | return $this->urlIsManagerPortal($url); |
||||
29 | } |
||||
30 | |||||
31 | public function isHrPortal() |
||||
32 | { |
||||
33 | $url = URL::current(); |
||||
34 | return $this->urlIsHrPortal($url); |
||||
35 | } |
||||
36 | |||||
37 | public function isAdminPortal() |
||||
38 | { |
||||
39 | $url = URL::current(); |
||||
40 | return $this->urlIsAdminPortal($url); |
||||
41 | } |
||||
42 | |||||
43 | public function urlIsManagerPortal($url): bool |
||||
44 | { |
||||
45 | $baseUrl = config('app.url'); |
||||
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
46 | $managerPrefix = config('app.manager_prefix'); |
||||
47 | $managerPattern = "#^$baseUrl/(\w+/)?$managerPrefix(/.*)?$#"; |
||||
48 | return preg_match($managerPattern, $url); |
||||
0 ignored issues
–
show
|
|||||
49 | } |
||||
50 | |||||
51 | public function urlIsHrPortal($url): bool |
||||
52 | { |
||||
53 | $baseUrl = config('app.url'); |
||||
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
54 | $hrPrefix = config('app.hr_prefix'); |
||||
55 | $hrPattern = "#^$baseUrl/(\w+/)?$hrPrefix(/.*)?$#"; |
||||
56 | return preg_match($hrPattern, $url); |
||||
0 ignored issues
–
show
|
|||||
57 | } |
||||
58 | |||||
59 | public function urlIsAdminPortal($url): bool |
||||
60 | { |
||||
61 | $baseUrl = config('app.url'); |
||||
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
62 | $adminPrefix = config('backpack.base.route_prefix', 'admin'); |
||||
63 | $adminPattern = "#^$baseUrl/(\w+/)?$adminPrefix(/.*)?$#"; |
||||
64 | return preg_match($adminPattern, $url); |
||||
0 ignored issues
–
show
|
|||||
65 | } |
||||
66 | |||||
67 | public function prefixRoute($routeName): string |
||||
68 | { |
||||
69 | if (WhichPortal::isApplicantPortal()) { |
||||
0 ignored issues
–
show
The method
App\Services\WhichPortal::isApplicantPortal() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
70 | return $routeName; |
||||
71 | } elseif (WhichPortal::isManagerPortal()) { |
||||
0 ignored issues
–
show
The method
App\Services\WhichPortal::isManagerPortal() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
72 | return 'manager.' . $routeName; |
||||
73 | } elseif (WhichPortal::isHrPortal()) { |
||||
0 ignored issues
–
show
The method
App\Services\WhichPortal::isHrPortal() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
74 | return 'hr_advisor.' . $routeName; |
||||
75 | } elseif (WhichPortal::isAdminPortal()) { |
||||
0 ignored issues
–
show
The method
App\Services\WhichPortal::isAdminPortal() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
76 | return 'admin.' . $routeName; |
||||
77 | } elseif (WhichPortal::isHrPortal()) { |
||||
78 | return 'hr_advisor.' . $routeName; |
||||
79 | } |
||||
80 | return $routeName; |
||||
81 | } |
||||
82 | } |
||||
83 |