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
|
2 |
|
public function compose(View $view) |
20
|
|
|
{ |
21
|
2 |
|
if (WhichPortal::isApplicantPortal()) { |
22
|
2 |
|
$menu = Lang::get('applicant/menu'); |
23
|
|
|
|
24
|
|
|
//Set active on the proper item |
25
|
2 |
|
switch(Route::currentRouteName()) { |
26
|
2 |
|
case 'home': |
27
|
|
|
$menu['items']['home']['active'] = true; |
28
|
|
|
break; |
29
|
2 |
|
case 'jobs.index': |
30
|
2 |
|
case 'jobs.show': |
31
|
2 |
|
case 'managers.show': |
32
|
|
|
$menu['items']['jobs']['active'] = true; |
33
|
|
|
break; |
34
|
2 |
|
case 'applications.index': |
35
|
2 |
|
case 'applications.edit': |
36
|
2 |
|
case 'applications.edit.1': |
37
|
2 |
|
case 'applications.edit.2': |
38
|
2 |
|
case 'applications.edit.3': |
39
|
2 |
|
case 'applications.edit.4': |
40
|
2 |
|
case 'applications.edit.5': |
41
|
2 |
|
case 'job.application.edit.1': |
42
|
2 |
|
case 'job.application.edit.2': |
43
|
2 |
|
case 'job.application.edit.3': |
44
|
2 |
|
case 'job.application.edit.4': |
45
|
2 |
|
case 'job.application.edit.5': |
46
|
|
|
$menu['items']['applications']['active'] = true; |
47
|
|
|
break; |
48
|
2 |
|
case 'profile': |
49
|
2 |
|
case 'profile.edit': |
50
|
2 |
|
case 'profile.show': |
51
|
2 |
|
case 'profile.about.edit': |
52
|
2 |
|
case 'profile.about.show': |
53
|
2 |
|
case 'profile.experience.edit': |
54
|
2 |
|
case 'profile.experience.show': |
55
|
2 |
|
case 'profile.references.edit': |
56
|
2 |
|
case 'profile.references.show': |
57
|
2 |
|
case 'profile.skills.edit': |
58
|
2 |
|
case 'profile.skills.show': |
59
|
2 |
|
case 'profile.work_samples.edit': |
60
|
2 |
|
case 'profile.work_samples.show': |
61
|
|
|
$menu['items']['profile']['active'] = true; |
62
|
|
|
break; |
63
|
2 |
|
case 'register': |
64
|
|
|
$menu['items']['register']['active'] = true; |
65
|
|
|
break; |
66
|
2 |
|
case 'login': |
67
|
|
|
$menu['items']['login']['active'] = true; |
68
|
|
|
break; |
69
|
2 |
|
case 'logout': |
70
|
|
|
$menu['items']['logout']['active'] = true; |
71
|
|
|
break; |
72
|
|
|
default: |
73
|
|
|
//No menu item will be active |
74
|
2 |
|
break; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
//Check if use is logged in, and remove invalid menu items |
78
|
2 |
|
if (Auth::check()) { |
79
|
|
|
unset($menu['items']['login']); |
80
|
|
|
unset($menu['items']['register']); |
81
|
|
|
//TODO set profile like using user slug |
82
|
|
|
} else { |
83
|
2 |
|
unset($menu['items']['logout']); |
84
|
2 |
|
unset($menu['items']['applications']); |
85
|
2 |
|
unset($menu['items']['profile']); |
86
|
|
|
} |
87
|
|
|
} else if (WhichPortal::isManagerPortal()) { |
88
|
|
|
$menu = Lang::get('manager/menu'); |
89
|
|
|
|
90
|
|
|
//Set active on the proper item |
91
|
|
|
switch(Route::currentRouteName()) { |
92
|
|
|
case 'manager.home': |
93
|
|
|
$menu['items']['home']['active'] = true; |
94
|
|
|
break; |
95
|
|
|
case 'manager.jobs.index': |
96
|
|
|
case 'manager.jobs.show': |
97
|
|
|
$menu['items']['jobs']['active'] = true; |
98
|
|
|
break; |
99
|
|
|
case 'manager.jobs.create': |
100
|
|
|
case 'manager.jobs.edit': |
101
|
|
|
case 'manager.jobs.update': |
102
|
|
|
$menu['items']['create_job']['active'] = true; |
103
|
|
|
break; |
104
|
|
|
case 'manager.profile': |
105
|
|
|
case 'manager.profile.edit': |
106
|
|
|
case 'manager.profile.show': |
107
|
|
|
$menu['items']['profile']['active'] = true; |
108
|
|
|
break; |
109
|
|
|
case 'register': |
110
|
|
|
$menu['items']['register']['active'] = true; |
111
|
|
|
break; |
112
|
|
|
case 'login': |
113
|
|
|
$menu['items']['login']['active'] = true; |
114
|
|
|
break; |
115
|
|
|
case 'logout': |
116
|
|
|
$menu['items']['logout']['active'] = true; |
117
|
|
|
break; |
118
|
|
|
default: |
119
|
|
|
//No menu item will be active |
120
|
|
|
break; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
//Check if use is logged in, and remove invalid menu items |
124
|
|
|
if (Auth::check()) { |
125
|
|
|
unset($menu['items']['login']); |
126
|
|
|
unset($menu['items']['register']); |
127
|
|
|
//TODO set profile like using user slug |
128
|
|
|
} else { |
129
|
|
|
unset($menu['items']['logout']); |
130
|
|
|
unset($menu['items']['jobs']); |
131
|
|
|
unset($menu['items']['create_job']); |
132
|
|
|
unset($menu['items']['profile']); |
133
|
|
|
} |
134
|
|
|
} |
135
|
2 |
|
if (WhichPortal::isManagerPortal()) { |
136
|
|
|
$loginModals = [ |
137
|
|
|
'modals' => Lang::get('common/login_modals'), |
138
|
|
|
'register_link' => route('manager.register'), |
139
|
|
|
'login_link' => route('manager.login'), |
140
|
|
|
'logout_link' => route('manager.logout'), |
141
|
|
|
]; |
142
|
|
|
} else { |
143
|
|
|
$loginModals = [ |
144
|
2 |
|
'modals' => Lang::get('common/login_modals'), |
145
|
2 |
|
'register_link' => route('register'), |
146
|
2 |
|
'login_link' => route('login'), |
147
|
2 |
|
'logout_link' => route('logout'), |
148
|
|
|
]; |
149
|
|
|
} |
150
|
|
|
|
151
|
2 |
|
$view->with('menu', $menu) |
|
|
|
|
152
|
2 |
|
->with('login_modals', $loginModals); |
153
|
2 |
|
} |
154
|
|
|
} |
155
|
|
|
|