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