@@ -51,7 +51,7 @@ |
||
51 | 51 | |
52 | 52 | if (is_null($product)) { |
53 | 53 | return response()->json(['code' => RepositoryException::RESOURCE_NOT_FOUND, |
54 | - 'message' => 'Product with ID ' . $id . ' not found'], 404); |
|
54 | + 'message' => 'Product with ID '.$id.' not found'], 404); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return response()->json($this->repository->APIFormat($product), 200); |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | class PublicController extends Controller { |
4 | 4 | |
5 | - // UNUSED |
|
6 | - public function home() |
|
7 | - { |
|
8 | - return view('public.home'); |
|
9 | - } |
|
5 | + // UNUSED |
|
6 | + public function home() |
|
7 | + { |
|
8 | + return view('public.home'); |
|
9 | + } |
|
10 | 10 | |
11 | 11 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $this->productRepository = $productRepository; |
21 | 21 | } |
22 | 22 | |
23 | - public function dashboard($interval=self::DEFAULT_INTERVAL) |
|
23 | + public function dashboard($interval = self::DEFAULT_INTERVAL) |
|
24 | 24 | { |
25 | 25 | $intervalData = $this->extractIntervalData($interval); |
26 | 26 | |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | $type = substr($intervalString, -1); |
49 | 49 | $nb = intval(substr($intervalString, 0, -1)); |
50 | 50 | |
51 | - if( $type=='h' ) |
|
51 | + if ($type == 'h') |
|
52 | 52 | { |
53 | - if( $nb>24 ) |
|
53 | + if ($nb>24) |
|
54 | 54 | { |
55 | 55 | $nb = 24; |
56 | 56 | } |
57 | 57 | |
58 | 58 | return CarbonInterval::hours($nb); |
59 | 59 | } |
60 | - elseif( $type=='d' ) |
|
60 | + elseif ($type == 'd') |
|
61 | 61 | { |
62 | - if( $nb>30 ) |
|
62 | + if ($nb>30) |
|
63 | 63 | { |
64 | 64 | $nb = 30; |
65 | 65 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | */ |
79 | 79 | private function getTitleFromInterval(CarbonInterval $interval) |
80 | 80 | { |
81 | - if( $interval->h>0 ) |
|
81 | + if ($interval->h>0) |
|
82 | 82 | return 'Last '.$interval->h.' hours'; |
83 | 83 | |
84 | - if( $interval->d>0 ) |
|
84 | + if ($interval->d>0) |
|
85 | 85 | return 'Last '.$interval->d.' days'; |
86 | 86 | |
87 | 87 | return 'Last '.$interval->forHumans(); |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | return CarbonInterval::hours($nb); |
59 | - } |
|
60 | - elseif( $type=='d' ) |
|
59 | + } elseif( $type=='d' ) |
|
61 | 60 | { |
62 | 61 | if( $nb>30 ) |
63 | 62 | { |
@@ -78,11 +77,13 @@ discard block |
||
78 | 77 | */ |
79 | 78 | private function getTitleFromInterval(CarbonInterval $interval) |
80 | 79 | { |
81 | - if( $interval->h>0 ) |
|
82 | - return 'Last '.$interval->h.' hours'; |
|
80 | + if( $interval->h>0 ) { |
|
81 | + return 'Last '.$interval->h.' hours'; |
|
82 | + } |
|
83 | 83 | |
84 | - if( $interval->d>0 ) |
|
85 | - return 'Last '.$interval->d.' days'; |
|
84 | + if( $interval->d>0 ) { |
|
85 | + return 'Last '.$interval->d.' days'; |
|
86 | + } |
|
86 | 87 | |
87 | 88 | return 'Last '.$interval->forHumans(); |
88 | 89 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public function dashboard() |
16 | 16 | { |
17 | 17 | $categories = Categories::allAPI(); |
18 | - $stockEmptyAlert = intval( $this->settingRepository->getValue(SettingRepository::STOCK_EMPTY_ALERT) ); |
|
18 | + $stockEmptyAlert = intval($this->settingRepository->getValue(SettingRepository::STOCK_EMPTY_ALERT)); |
|
19 | 19 | |
20 | 20 | return view('stock.app')->with('categories', $categories) |
21 | 21 | ->with('stockEmptyAlert', $stockEmptyAlert); |
@@ -8,34 +8,34 @@ discard block |
||
8 | 8 | |
9 | 9 | class UsersController extends Controller { |
10 | 10 | |
11 | - private $userRepository; |
|
11 | + private $userRepository; |
|
12 | 12 | private $connectRepository; |
13 | 13 | |
14 | - public function __construct(UserRepository $repository, ConnectRepository $connectRepository) |
|
15 | - { |
|
16 | - $this->userRepository = $repository; |
|
14 | + public function __construct(UserRepository $repository, ConnectRepository $connectRepository) |
|
15 | + { |
|
16 | + $this->userRepository = $repository; |
|
17 | 17 | $this->connectRepository = $connectRepository; |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function getActiveUsers() |
21 | 21 | { |
22 | - $allUsers = $this->userRepository->allByStatus(true); |
|
22 | + $allUsers = $this->userRepository->allByStatus(true); |
|
23 | 23 | $otherUsersCount = count($this->userRepository->allByStatus(false)); |
24 | 24 | |
25 | 25 | return view('users.app')->with('users', $allUsers) |
26 | - ->with('roles', $this->getRoleNames()) |
|
27 | - ->with('isActive', true) |
|
26 | + ->with('roles', $this->getRoleNames()) |
|
27 | + ->with('isActive', true) |
|
28 | 28 | ->with('otherUsersCount', $otherUsersCount); |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function getDisabledUsers() |
32 | 32 | { |
33 | - $allUsers = $this->userRepository->allByStatus(false); |
|
33 | + $allUsers = $this->userRepository->allByStatus(false); |
|
34 | 34 | $otherUsersCount = count($this->userRepository->allByStatus(true)); |
35 | 35 | |
36 | - return view('users.app')->with('users', $allUsers) |
|
37 | - ->with('roles', $this->getRoleNames()) |
|
38 | - ->with('isActive', false) |
|
36 | + return view('users.app')->with('users', $allUsers) |
|
37 | + ->with('roles', $this->getRoleNames()) |
|
38 | + ->with('isActive', false) |
|
39 | 39 | ->with('otherUsersCount', $otherUsersCount); |
40 | 40 | } |
41 | 41 | |
@@ -50,70 +50,70 @@ discard block |
||
50 | 50 | |
51 | 51 | public function getRegisterForm() |
52 | 52 | { |
53 | - return view('users.register'); |
|
53 | + return view('users.register'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function registerNewUser() |
57 | 57 | { |
58 | - try { |
|
59 | - $user = $this->userRepository->store(Input::all()); |
|
60 | - } |
|
58 | + try { |
|
59 | + $user = $this->userRepository->store(Input::all()); |
|
60 | + } |
|
61 | 61 | catch(ValidationException $e) { |
62 | 62 | return redirect('app/users/register')->withInput() |
63 | - ->with('error', $e->getMessageBag()->first()); |
|
63 | + ->with('error', $e->getMessageBag()->first()); |
|
64 | 64 | } |
65 | 65 | catch (RepositoryException $e) { |
66 | - return redirect('app/users/register')->with('error', 'Could not add new user: '.strtolower($e->getMessage())) |
|
67 | - ->withInput(); |
|
68 | - } |
|
66 | + return redirect('app/users/register')->with('error', 'Could not add new user: '.strtolower($e->getMessage())) |
|
67 | + ->withInput(); |
|
68 | + } |
|
69 | 69 | |
70 | - return redirect('app/users')->with('success', $user->firstname.' account added'); |
|
70 | + return redirect('app/users')->with('success', $user->firstname.' account added'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | public function changeAccountStatus($userId) |
74 | 74 | { |
75 | - try { |
|
76 | - $user = $this->userRepository->changeStatus($userId); |
|
77 | - } |
|
78 | - catch(RepositoryException $e) { |
|
79 | - return redirect('app/users')->with('error', 'Could not change account status'); |
|
80 | - } |
|
75 | + try { |
|
76 | + $user = $this->userRepository->changeStatus($userId); |
|
77 | + } |
|
78 | + catch(RepositoryException $e) { |
|
79 | + return redirect('app/users')->with('error', 'Could not change account status'); |
|
80 | + } |
|
81 | 81 | |
82 | - if($user->is_active) |
|
83 | - return redirect('app/users/disabled')->with('success', 'User <b>'.$user->firstname.'</b> enabled'); |
|
84 | - else |
|
85 | - return redirect('app/users')->with('success', 'User <b>'.$user->firstname.'</b> disabled'); |
|
82 | + if($user->is_active) |
|
83 | + return redirect('app/users/disabled')->with('success', 'User <b>'.$user->firstname.'</b> enabled'); |
|
84 | + else |
|
85 | + return redirect('app/users')->with('success', 'User <b>'.$user->firstname.'</b> disabled'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | public function changeAccountRole($userId) |
89 | 89 | { |
90 | - try { |
|
91 | - $user = $this->userRepository->changeRole($userId); |
|
92 | - } |
|
93 | - catch(RepositoryException $e) { |
|
94 | - return redirect('app/users')->with('error', 'Could not change user role'); |
|
95 | - } |
|
90 | + try { |
|
91 | + $user = $this->userRepository->changeRole($userId); |
|
92 | + } |
|
93 | + catch(RepositoryException $e) { |
|
94 | + return redirect('app/users')->with('error', 'Could not change user role'); |
|
95 | + } |
|
96 | 96 | |
97 | - $redirectUrl = 'app/users'; |
|
98 | - if( !$user->is_active ) |
|
99 | - $redirectUrl .= '/disabled'; |
|
97 | + $redirectUrl = 'app/users'; |
|
98 | + if( !$user->is_active ) |
|
99 | + $redirectUrl .= '/disabled'; |
|
100 | 100 | |
101 | - $roleNames = ['ADMN'=>'administrator','MNGR'=>'manager','USER'=>'user']; |
|
102 | - $roleName = $roleNames[$user->role]; |
|
101 | + $roleNames = ['ADMN'=>'administrator','MNGR'=>'manager','USER'=>'user']; |
|
102 | + $roleName = $roleNames[$user->role]; |
|
103 | 103 | |
104 | - return redirect($redirectUrl)->with('success', 'User <b>'.$user->firstname.'</b> is now <i>'.$roleName.'</i>'); |
|
104 | + return redirect($redirectUrl)->with('success', 'User <b>'.$user->firstname.'</b> is now <i>'.$roleName.'</i>'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | public function deleteUser($userId) |
108 | 108 | { |
109 | - try { |
|
110 | - $user = $this->userRepository->softDelete($userId); |
|
111 | - } |
|
112 | - catch(RepositoryException $e) { |
|
113 | - return redirect('app/users')->with('error', 'User could not be deleted: '.$e->getMessage()); |
|
114 | - } |
|
109 | + try { |
|
110 | + $user = $this->userRepository->softDelete($userId); |
|
111 | + } |
|
112 | + catch(RepositoryException $e) { |
|
113 | + return redirect('app/users')->with('error', 'User could not be deleted: '.$e->getMessage()); |
|
114 | + } |
|
115 | 115 | |
116 | - return redirect('app/users')->with('success', 'User <b>'.$user->firstname.'</b> deleted'); |
|
116 | + return redirect('app/users')->with('success', 'User <b>'.$user->firstname.'</b> deleted'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | private function getRoleNames() |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | try { |
59 | 59 | $user = $this->userRepository->store(Input::all()); |
60 | 60 | } |
61 | - catch(ValidationException $e) { |
|
61 | + catch (ValidationException $e) { |
|
62 | 62 | return redirect('app/users/register')->withInput() |
63 | 63 | ->with('error', $e->getMessageBag()->first()); |
64 | 64 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | try { |
76 | 76 | $user = $this->userRepository->changeStatus($userId); |
77 | 77 | } |
78 | - catch(RepositoryException $e) { |
|
78 | + catch (RepositoryException $e) { |
|
79 | 79 | return redirect('app/users')->with('error', 'Could not change account status'); |
80 | 80 | } |
81 | 81 | |
82 | - if($user->is_active) |
|
82 | + if ($user->is_active) |
|
83 | 83 | return redirect('app/users/disabled')->with('success', 'User <b>'.$user->firstname.'</b> enabled'); |
84 | 84 | else |
85 | 85 | return redirect('app/users')->with('success', 'User <b>'.$user->firstname.'</b> disabled'); |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | try { |
91 | 91 | $user = $this->userRepository->changeRole($userId); |
92 | 92 | } |
93 | - catch(RepositoryException $e) { |
|
93 | + catch (RepositoryException $e) { |
|
94 | 94 | return redirect('app/users')->with('error', 'Could not change user role'); |
95 | 95 | } |
96 | 96 | |
97 | 97 | $redirectUrl = 'app/users'; |
98 | - if( !$user->is_active ) |
|
98 | + if (!$user->is_active) |
|
99 | 99 | $redirectUrl .= '/disabled'; |
100 | 100 | |
101 | - $roleNames = ['ADMN'=>'administrator','MNGR'=>'manager','USER'=>'user']; |
|
101 | + $roleNames = ['ADMN'=>'administrator', 'MNGR'=>'manager', 'USER'=>'user']; |
|
102 | 102 | $roleName = $roleNames[$user->role]; |
103 | 103 | |
104 | 104 | return redirect($redirectUrl)->with('success', 'User <b>'.$user->firstname.'</b> is now <i>'.$roleName.'</i>'); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | try { |
110 | 110 | $user = $this->userRepository->softDelete($userId); |
111 | 111 | } |
112 | - catch(RepositoryException $e) { |
|
112 | + catch (RepositoryException $e) { |
|
113 | 113 | return redirect('app/users')->with('error', 'User could not be deleted: '.$e->getMessage()); |
114 | 114 | } |
115 | 115 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | private function getRoleNames() |
120 | 120 | { |
121 | - return ['ADMN'=>'Administrator','MNGR'=>'Manager','USER'=>'User']; |
|
121 | + return ['ADMN'=>'Administrator', 'MNGR'=>'Manager', 'USER'=>'User']; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | } |
@@ -57,12 +57,10 @@ discard block |
||
57 | 57 | { |
58 | 58 | try { |
59 | 59 | $user = $this->userRepository->store(Input::all()); |
60 | - } |
|
61 | - catch(ValidationException $e) { |
|
60 | + } catch(ValidationException $e) { |
|
62 | 61 | return redirect('app/users/register')->withInput() |
63 | 62 | ->with('error', $e->getMessageBag()->first()); |
64 | - } |
|
65 | - catch (RepositoryException $e) { |
|
63 | + } catch (RepositoryException $e) { |
|
66 | 64 | return redirect('app/users/register')->with('error', 'Could not add new user: '.strtolower($e->getMessage())) |
67 | 65 | ->withInput(); |
68 | 66 | } |
@@ -74,29 +72,29 @@ discard block |
||
74 | 72 | { |
75 | 73 | try { |
76 | 74 | $user = $this->userRepository->changeStatus($userId); |
77 | - } |
|
78 | - catch(RepositoryException $e) { |
|
75 | + } catch(RepositoryException $e) { |
|
79 | 76 | return redirect('app/users')->with('error', 'Could not change account status'); |
80 | 77 | } |
81 | 78 | |
82 | - if($user->is_active) |
|
83 | - return redirect('app/users/disabled')->with('success', 'User <b>'.$user->firstname.'</b> enabled'); |
|
84 | - else |
|
85 | - return redirect('app/users')->with('success', 'User <b>'.$user->firstname.'</b> disabled'); |
|
79 | + if($user->is_active) { |
|
80 | + return redirect('app/users/disabled')->with('success', 'User <b>'.$user->firstname.'</b> enabled'); |
|
81 | + } else { |
|
82 | + return redirect('app/users')->with('success', 'User <b>'.$user->firstname.'</b> disabled'); |
|
83 | + } |
|
86 | 84 | } |
87 | 85 | |
88 | 86 | public function changeAccountRole($userId) |
89 | 87 | { |
90 | 88 | try { |
91 | 89 | $user = $this->userRepository->changeRole($userId); |
92 | - } |
|
93 | - catch(RepositoryException $e) { |
|
90 | + } catch(RepositoryException $e) { |
|
94 | 91 | return redirect('app/users')->with('error', 'Could not change user role'); |
95 | 92 | } |
96 | 93 | |
97 | 94 | $redirectUrl = 'app/users'; |
98 | - if( !$user->is_active ) |
|
99 | - $redirectUrl .= '/disabled'; |
|
95 | + if( !$user->is_active ) { |
|
96 | + $redirectUrl .= '/disabled'; |
|
97 | + } |
|
100 | 98 | |
101 | 99 | $roleNames = ['ADMN'=>'administrator','MNGR'=>'manager','USER'=>'user']; |
102 | 100 | $roleName = $roleNames[$user->role]; |
@@ -108,8 +106,7 @@ discard block |
||
108 | 106 | { |
109 | 107 | try { |
110 | 108 | $user = $this->userRepository->softDelete($userId); |
111 | - } |
|
112 | - catch(RepositoryException $e) { |
|
109 | + } catch(RepositoryException $e) { |
|
113 | 110 | return redirect('app/users')->with('error', 'User could not be deleted: '.$e->getMessage()); |
114 | 111 | } |
115 | 112 |
@@ -4,33 +4,33 @@ |
||
4 | 4 | |
5 | 5 | class Kernel extends HttpKernel { |
6 | 6 | |
7 | - /** |
|
8 | - * The application's global HTTP middleware stack. |
|
9 | - * |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $middleware = [ |
|
13 | - 'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode', |
|
14 | - 'Illuminate\Cookie\Middleware\EncryptCookies', |
|
15 | - 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', |
|
16 | - 'Illuminate\Session\Middleware\StartSession', |
|
17 | - 'Illuminate\View\Middleware\ShareErrorsFromSession', |
|
18 | - 'App\Http\Middleware\VerifyCsrfToken', |
|
19 | - ]; |
|
7 | + /** |
|
8 | + * The application's global HTTP middleware stack. |
|
9 | + * |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $middleware = [ |
|
13 | + 'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode', |
|
14 | + 'Illuminate\Cookie\Middleware\EncryptCookies', |
|
15 | + 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', |
|
16 | + 'Illuminate\Session\Middleware\StartSession', |
|
17 | + 'Illuminate\View\Middleware\ShareErrorsFromSession', |
|
18 | + 'App\Http\Middleware\VerifyCsrfToken', |
|
19 | + ]; |
|
20 | 20 | |
21 | - /** |
|
22 | - * The application's route middleware. |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected $routeMiddleware = [ |
|
27 | - 'auth' => 'App\Http\Middleware\Authenticate', |
|
28 | - 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth', |
|
29 | - 'guest' => 'App\Http\Middleware\RedirectIfAuthenticated', |
|
21 | + /** |
|
22 | + * The application's route middleware. |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected $routeMiddleware = [ |
|
27 | + 'auth' => 'App\Http\Middleware\Authenticate', |
|
28 | + 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth', |
|
29 | + 'guest' => 'App\Http\Middleware\RedirectIfAuthenticated', |
|
30 | 30 | 'user' => 'App\Http\Middleware\User', |
31 | 31 | 'manager' => 'App\Http\Middleware\Manager', |
32 | 32 | 'administrator' => 'App\Http\Middleware\Administrator', |
33 | 33 | 'installed' => 'App\Http\Middleware\RedirectIfInstalled', |
34 | - ]; |
|
34 | + ]; |
|
35 | 35 | |
36 | 36 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | public function handle($request, Closure $next) |
16 | 16 | { |
17 | - if ($this->auth->guest() || session('role')!=='ADMN' ) |
|
17 | + if ($this->auth->guest() || session('role') !== 'ADMN') |
|
18 | 18 | { |
19 | 19 | if ($request->ajax()) |
20 | 20 | { |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | $this->auth = $auth; |
13 | 13 | } |
14 | 14 | |
15 | - public function handle($request, Closure $next) |
|
16 | - { |
|
15 | + public function handle($request, Closure $next) |
|
16 | + { |
|
17 | 17 | if ($this->auth->guest() || (session('role')!=='USER' && session('role')!=='MNGR' && session('role')!=='ADMN') ) |
18 | 18 | { |
19 | 19 | if ($request->ajax()) |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | - return $next($request); |
|
30 | - } |
|
29 | + return $next($request); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |
@@ -19,8 +19,7 @@ |
||
19 | 19 | if ($request->ajax()) |
20 | 20 | { |
21 | 21 | return response('Unauthorized.', 401); |
22 | - } |
|
23 | - else |
|
22 | + } else |
|
24 | 23 | { |
25 | 24 | return redirect()->guest('/'); |
26 | 25 | } |
@@ -37,8 +37,7 @@ |
||
37 | 37 | if ($request->ajax()) |
38 | 38 | { |
39 | 39 | return response('Unauthorized.', 401); |
40 | - } |
|
41 | - else |
|
40 | + } else |
|
42 | 41 | { |
43 | 42 | return redirect()->guest('/'); |
44 | 43 | } |
@@ -5,45 +5,45 @@ |
||
5 | 5 | |
6 | 6 | class Authenticate { |
7 | 7 | |
8 | - /** |
|
9 | - * The Guard implementation. |
|
10 | - * |
|
11 | - * @var Guard |
|
12 | - */ |
|
13 | - protected $auth; |
|
8 | + /** |
|
9 | + * The Guard implementation. |
|
10 | + * |
|
11 | + * @var Guard |
|
12 | + */ |
|
13 | + protected $auth; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Create a new filter instance. |
|
17 | - * |
|
18 | - * @param Guard $auth |
|
19 | - */ |
|
20 | - public function __construct(Guard $auth) |
|
21 | - { |
|
22 | - $this->auth = $auth; |
|
23 | - } |
|
15 | + /** |
|
16 | + * Create a new filter instance. |
|
17 | + * |
|
18 | + * @param Guard $auth |
|
19 | + */ |
|
20 | + public function __construct(Guard $auth) |
|
21 | + { |
|
22 | + $this->auth = $auth; |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Handle an incoming request. |
|
27 | - * |
|
28 | - * @param \Illuminate\Http\Request $request |
|
29 | - * @param \Closure $next |
|
30 | - * @return mixed |
|
31 | - */ |
|
32 | - public function handle($request, Closure $next) |
|
33 | - { |
|
34 | - if ($this->auth->guest()) |
|
35 | - { |
|
36 | - if ($request->ajax()) |
|
37 | - { |
|
38 | - return response('Unauthorized.', 401); |
|
39 | - } |
|
40 | - else |
|
41 | - { |
|
42 | - return redirect()->guest('/'); |
|
43 | - } |
|
44 | - } |
|
25 | + /** |
|
26 | + * Handle an incoming request. |
|
27 | + * |
|
28 | + * @param \Illuminate\Http\Request $request |
|
29 | + * @param \Closure $next |
|
30 | + * @return mixed |
|
31 | + */ |
|
32 | + public function handle($request, Closure $next) |
|
33 | + { |
|
34 | + if ($this->auth->guest()) |
|
35 | + { |
|
36 | + if ($request->ajax()) |
|
37 | + { |
|
38 | + return response('Unauthorized.', 401); |
|
39 | + } |
|
40 | + else |
|
41 | + { |
|
42 | + return redirect()->guest('/'); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | - return $next($request); |
|
47 | - } |
|
46 | + return $next($request); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | public function handle($request, Closure $next) |
16 | 16 | { |
17 | - if ($this->auth->guest() || (session('role')!=='MNGR' && session('role')!=='ADMN') ) |
|
17 | + if ($this->auth->guest() || (session('role') !== 'MNGR' && session('role') !== 'ADMN')) |
|
18 | 18 | { |
19 | 19 | if ($request->ajax()) |
20 | 20 | { |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | $this->auth = $auth; |
13 | 13 | } |
14 | 14 | |
15 | - public function handle($request, Closure $next) |
|
16 | - { |
|
15 | + public function handle($request, Closure $next) |
|
16 | + { |
|
17 | 17 | if ($this->auth->guest() || (session('role')!=='USER' && session('role')!=='MNGR' && session('role')!=='ADMN') ) |
18 | 18 | { |
19 | 19 | if ($request->ajax()) |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | - return $next($request); |
|
30 | - } |
|
29 | + return $next($request); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |
@@ -19,8 +19,7 @@ |
||
19 | 19 | if ($request->ajax()) |
20 | 20 | { |
21 | 21 | return response('Unauthorized.', 401); |
22 | - } |
|
23 | - else |
|
22 | + } else |
|
24 | 23 | { |
25 | 24 | return redirect()->guest('/'); |
26 | 25 | } |