1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
namespace App\Http\ViewComposers; |
4
|
|
|
|
5
|
|
|
use Illuminate\View\View; |
6
|
|
|
use Illuminate\Support\Facades\Lang; |
7
|
|
|
use Illuminate\Support\Facades\Route; |
8
|
|
|
use Illuminate\Support\Facades\Auth; |
9
|
|
|
use Facades\App\Services\WhichPortal; |
10
|
|
|
|
11
|
|
|
class MenuComposer |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Bind data to the view. |
15
|
|
|
* |
16
|
|
|
* @param View $view |
|
|
|
|
17
|
|
|
* @return void |
|
|
|
|
18
|
|
|
*/ |
19
|
28 |
|
public function compose(View $view) |
20
|
|
|
{ |
21
|
28 |
|
if (WhichPortal::isApplicantPortal()) { |
22
|
20 |
|
$menu = Lang::get('applicant/menu'); |
23
|
|
|
|
24
|
|
|
//Set active on the proper item |
25
|
20 |
|
switch(Route::currentRouteName()) { |
26
|
20 |
|
case 'home': |
27
|
10 |
|
$menu['items']['home']['active'] = true; |
28
|
10 |
|
break; |
29
|
10 |
|
case 'jobs.index': |
30
|
10 |
|
case 'jobs.show': |
31
|
6 |
|
case 'managers.show': |
32
|
4 |
|
$menu['items']['jobs']['active'] = true; |
33
|
4 |
|
break; |
34
|
6 |
|
case 'applications.index': |
35
|
6 |
|
case 'applications.edit': |
36
|
6 |
|
case 'applications.edit.1': |
37
|
6 |
|
case 'applications.edit.2': |
38
|
6 |
|
case 'applications.edit.3': |
39
|
6 |
|
case 'applications.edit.4': |
40
|
6 |
|
case 'applications.edit.5': |
41
|
6 |
|
case 'job.application.edit.1': |
42
|
6 |
|
case 'job.application.edit.2': |
43
|
6 |
|
case 'job.application.edit.3': |
44
|
6 |
|
case 'job.application.edit.4': |
45
|
6 |
|
case 'job.application.edit.5': |
46
|
6 |
|
case 'job.application.complete': |
47
|
|
|
$menu['items']['applications']['active'] = true; |
48
|
|
|
break; |
49
|
6 |
|
case 'profile': |
50
|
6 |
|
case 'profile.edit': |
51
|
6 |
|
case 'profile.show': |
52
|
6 |
|
case 'profile.about.edit': |
53
|
6 |
|
case 'profile.about.show': |
54
|
6 |
|
case 'profile.experience.edit': |
55
|
6 |
|
case 'profile.experience.show': |
56
|
6 |
|
case 'profile.references.edit': |
57
|
6 |
|
case 'profile.references.show': |
58
|
6 |
|
case 'profile.skills.edit': |
59
|
6 |
|
case 'profile.skills.show': |
60
|
6 |
|
case 'profile.work_samples.edit': |
61
|
6 |
|
case 'profile.work_samples.show': |
62
|
|
|
$menu['items']['profile']['active'] = true; |
63
|
|
|
break; |
64
|
6 |
|
case 'register': |
65
|
2 |
|
$menu['items']['register']['active'] = true; |
66
|
2 |
|
break; |
67
|
4 |
|
case 'login': |
68
|
4 |
|
$menu['items']['login']['active'] = true; |
69
|
4 |
|
break; |
70
|
|
|
case 'logout': |
71
|
|
|
$menu['items']['logout']['active'] = true; |
72
|
|
|
break; |
73
|
|
|
case 'faq': |
74
|
|
|
$menu['items']['faq']['active'] = true; |
75
|
|
|
break; |
76
|
|
|
default: |
77
|
|
|
//No menu item will be active |
78
|
|
|
break; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
//Set route links |
82
|
20 |
|
$menu['items']['home']['link'] = route('home'); |
83
|
20 |
|
$menu['items']['jobs']['link'] = route('jobs.index'); |
84
|
20 |
|
$menu['items']['applications']['link'] = route('applications.index'); |
85
|
20 |
|
$menu['items']['profile']['link'] = route('profile'); |
86
|
20 |
|
$menu['items']['faq']['link'] = route('faq'); |
87
|
|
|
|
88
|
|
|
//Check if use is logged in, and remove invalid menu items |
89
|
20 |
|
if (Auth::check()) { |
90
|
8 |
|
unset($menu['items']['login']); |
91
|
8 |
|
unset($menu['items']['register']); |
92
|
|
|
//TODO set profile like using user slug |
93
|
|
|
} else { |
94
|
16 |
|
unset($menu['items']['logout']); |
95
|
16 |
|
unset($menu['items']['applications']); |
96
|
20 |
|
unset($menu['items']['profile']); |
97
|
|
|
} |
98
|
8 |
|
} else if (WhichPortal::isManagerPortal()) { |
99
|
8 |
|
$menu = Lang::get('manager/menu'); |
100
|
|
|
|
101
|
|
|
//Set active on the proper item |
102
|
8 |
|
switch(Route::currentRouteName()) { |
103
|
8 |
|
case 'manager.home': |
104
|
|
|
$menu['items']['home']['active'] = true; |
105
|
|
|
break; |
106
|
8 |
|
case 'manager.jobs.index': |
107
|
6 |
|
case 'manager.jobs.show': |
108
|
4 |
|
$menu['items']['jobs']['active'] = true; |
109
|
4 |
|
break; |
110
|
4 |
|
case 'manager.jobs.create': |
111
|
2 |
|
case 'manager.jobs.edit': |
112
|
|
|
case 'manager.jobs.update': |
113
|
4 |
|
$menu['items']['create_job']['active'] = true; |
114
|
4 |
|
break; |
115
|
|
|
case 'manager.profile': |
116
|
|
|
case 'manager.profile.edit': |
117
|
|
|
case 'manager.profile.show': |
118
|
|
|
$menu['items']['profile']['active'] = true; |
119
|
|
|
break; |
120
|
|
|
case 'register': |
121
|
|
|
$menu['items']['register']['active'] = true; |
122
|
|
|
break; |
123
|
|
|
case 'login': |
124
|
|
|
$menu['items']['login']['active'] = true; |
125
|
|
|
break; |
126
|
|
|
case 'logout': |
127
|
|
|
$menu['items']['logout']['active'] = true; |
128
|
|
|
break; |
129
|
|
|
case 'faq': |
130
|
|
|
$menu['items']['faq']['active'] = true; |
131
|
|
|
break; |
132
|
|
|
default: |
133
|
|
|
//No menu item will be active |
134
|
|
|
break; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
//Set route links |
138
|
8 |
|
$menu['items']['home']['link'] = route('manager.home'); |
139
|
8 |
|
$menu['items']['jobs']['link'] = route('manager.jobs.index'); |
140
|
8 |
|
$menu['items']['create_job']['link'] = route('manager.jobs.create'); |
141
|
8 |
|
$menu['items']['profile']['link'] = route('manager.profile'); |
142
|
|
|
|
143
|
|
|
//Check if use is logged in, and remove invalid menu items |
144
|
8 |
|
if (Auth::check()) { |
145
|
8 |
|
unset($menu['items']['login']); |
146
|
8 |
|
unset($menu['items']['register']); |
147
|
|
|
//TODO set profile like using user slug |
148
|
|
|
} else { |
149
|
|
|
unset($menu['items']['logout']); |
150
|
|
|
unset($menu['items']['jobs']); |
151
|
|
|
unset($menu['items']['create_job']); |
152
|
|
|
unset($menu['items']['profile']); |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
//Set login modals data |
156
|
28 |
|
if (WhichPortal::isManagerPortal()) { |
157
|
|
|
$loginModals = [ |
158
|
8 |
|
'modals' => Lang::get('common/login_modals'), |
159
|
8 |
|
'register_link' => route('manager.register'), |
160
|
8 |
|
'login_link' => route('manager.login'), |
161
|
8 |
|
'logout_link' => route('manager.logout'), |
162
|
|
|
]; |
163
|
|
|
} else { |
164
|
|
|
$loginModals = [ |
165
|
20 |
|
'modals' => Lang::get('common/login_modals'), |
166
|
20 |
|
'register_link' => route('register'), |
167
|
20 |
|
'login_link' => route('login'), |
168
|
20 |
|
'logout_link' => route('logout'), |
169
|
|
|
]; |
170
|
|
|
} |
171
|
|
|
|
172
|
28 |
|
$view->with('menu', $menu) |
|
|
|
|
173
|
28 |
|
->with('login_modals', $loginModals); |
174
|
28 |
|
} |
175
|
|
|
} |
176
|
|
|
|