@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | const NB_USERS = 20; |
16 | 16 | const MAX_NB_PRODUCTS = 9; |
17 | 17 | |
18 | - protected $name = 'db:faker'; |
|
19 | - protected $description = 'Seed the database with fake data for testing purposes'; |
|
18 | + protected $name = 'db:faker'; |
|
19 | + protected $description = 'Seed the database with fake data for testing purposes'; |
|
20 | 20 | |
21 | 21 | private $faker; |
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - parent::__construct(); |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + parent::__construct(); |
|
26 | 26 | |
27 | 27 | $this->faker = Factory::create(); |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - public function fire() |
|
31 | - { |
|
30 | + public function fire() |
|
31 | + { |
|
32 | 32 | $this->error("\nWatch out!"); |
33 | 33 | $this->info('This command will truncate all your Barmate data.'); |
34 | 34 | $this->info("Use this command only for testing purposes.\n"); |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | $this->seedCategories($groupId); |
49 | 49 | |
50 | 50 | $this->info("\nFake data successfully created. Happy testing!"); |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - protected function getArguments() |
|
54 | - { |
|
55 | - return []; |
|
56 | - } |
|
53 | + protected function getArguments() |
|
54 | + { |
|
55 | + return []; |
|
56 | + } |
|
57 | 57 | |
58 | - protected function getOptions() |
|
59 | - { |
|
60 | - return []; |
|
61 | - } |
|
58 | + protected function getOptions() |
|
59 | + { |
|
60 | + return []; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | private function seedUsers($groupId) |
64 | 64 | { |
@@ -5,28 +5,28 @@ |
||
5 | 5 | |
6 | 6 | class Inspire extends Command { |
7 | 7 | |
8 | - /** |
|
9 | - * The console command name. |
|
10 | - * |
|
11 | - * @var string |
|
12 | - */ |
|
13 | - protected $name = 'inspire'; |
|
8 | + /** |
|
9 | + * The console command name. |
|
10 | + * |
|
11 | + * @var string |
|
12 | + */ |
|
13 | + protected $name = 'inspire'; |
|
14 | 14 | |
15 | - /** |
|
16 | - * The console command description. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $description = 'Display an inspiring quote'; |
|
15 | + /** |
|
16 | + * The console command description. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $description = 'Display an inspiring quote'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Execute the console command. |
|
24 | - * |
|
25 | - * @return mixed |
|
26 | - */ |
|
27 | - public function handle() |
|
28 | - { |
|
29 | - $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); |
|
30 | - } |
|
22 | + /** |
|
23 | + * Execute the console command. |
|
24 | + * |
|
25 | + * @return mixed |
|
26 | + */ |
|
27 | + public function handle() |
|
28 | + { |
|
29 | + $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |
@@ -5,26 +5,26 @@ |
||
5 | 5 | |
6 | 6 | class Kernel extends ConsoleKernel { |
7 | 7 | |
8 | - /** |
|
9 | - * The Artisan commands provided by your application. |
|
10 | - * |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - protected $commands = [ |
|
14 | - 'App\Console\Commands\Inspire', |
|
8 | + /** |
|
9 | + * The Artisan commands provided by your application. |
|
10 | + * |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + protected $commands = [ |
|
14 | + 'App\Console\Commands\Inspire', |
|
15 | 15 | 'App\Console\Commands\DatabaseFaker' |
16 | - ]; |
|
16 | + ]; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Define the application's command schedule. |
|
20 | - * |
|
21 | - * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - protected function schedule(Schedule $schedule) |
|
25 | - { |
|
26 | - $schedule->command('inspire') |
|
27 | - ->hourly(); |
|
28 | - } |
|
18 | + /** |
|
19 | + * Define the application's command schedule. |
|
20 | + * |
|
21 | + * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + protected function schedule(Schedule $schedule) |
|
25 | + { |
|
26 | + $schedule->command('inspire') |
|
27 | + ->hourly(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | } |
@@ -9,139 +9,139 @@ |
||
9 | 9 | |
10 | 10 | class CategoryController extends Controller { |
11 | 11 | |
12 | - /** |
|
13 | - * Display a listing of the resource. |
|
14 | - * |
|
15 | - * @return Response |
|
16 | - */ |
|
17 | - public function index() |
|
18 | - { |
|
19 | - $categoriesFromGroup = Categories::allAPI(); |
|
20 | - |
|
21 | - return Response::json( $categoriesFromGroup, 200); |
|
22 | - } |
|
23 | - |
|
24 | - /** |
|
25 | - * Store a newly created resource in storage. |
|
26 | - * |
|
27 | - * @return Response |
|
28 | - */ |
|
29 | - public function store() |
|
30 | - { |
|
31 | - $validator = Validator::make(Input::all(), [ |
|
32 | - 'title' => 'required|alpha|between:1,50', |
|
33 | - 'description' => '' |
|
34 | - ]); |
|
35 | - |
|
36 | - if( $validator->fails() ) { |
|
37 | - return Response::json( ['code'=>1, 'error'=>'Validation failed'], 400); |
|
38 | - } |
|
39 | - |
|
40 | - $category = new Categories(); |
|
41 | - $category->group_id = Session::get('groupID'); |
|
42 | - $category->category_title = Input::get('title'); |
|
43 | - $category->description = Input::get('description'); |
|
44 | - $category->is_active = true; |
|
45 | - |
|
46 | - if( !$category->save() ) { |
|
47 | - |
|
48 | - return Response::json( ['code'=>2, 'error'=>'Database error'], 400); |
|
49 | - } |
|
50 | - |
|
51 | - return Response::json( ['id' => DB::getPdo()->lastInsertId() ], 200); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Display the specified resource. |
|
57 | - * |
|
58 | - * @param int $id |
|
59 | - * @return Response |
|
60 | - */ |
|
61 | - public function show($id) |
|
62 | - { |
|
63 | - if( !$this->isID($id) ) |
|
64 | - return Response::json( ['code'=>1, 'error'=>'Parameter must be an integer'], 400); |
|
65 | - |
|
66 | - $category = Categories::fromGroup()->find($id); |
|
67 | - |
|
68 | - if( $category == null ) |
|
69 | - return Response::json(); |
|
70 | - |
|
71 | - return Response::json($category, 200); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * Update the specified resource in storage. |
|
77 | - * |
|
78 | - * @param int $id |
|
79 | - * @return Response |
|
80 | - */ |
|
81 | - public function update($id) |
|
82 | - { |
|
83 | - $validator = Validator::make(Input::all(), [ |
|
84 | - 'title' => 'required|alpha|between:1,50', |
|
85 | - 'description' => '' |
|
86 | - ]); |
|
87 | - |
|
88 | - if( $validator->fails() ) { |
|
89 | - return Response::json( ['code'=>3, 'error'=>'Validation failed'], 400); |
|
90 | - } |
|
91 | - |
|
92 | - if( !$this->isID($id) ) |
|
93 | - return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400); |
|
94 | - |
|
95 | - $category = Categories::fromGroup()->find($id); |
|
96 | - |
|
97 | - if( $category == null ) |
|
98 | - return Response::json( ['code'=>2, 'error'=>'Category not found'] , 400); |
|
99 | - |
|
100 | - $category->category_title = Input::get('title'); |
|
101 | - $category->description = Input::get('description'); |
|
102 | - |
|
103 | - if( !$category->save() ) { |
|
104 | - |
|
105 | - return Response::json( ['code'=>2, 'error'=>'Database error'], 400); |
|
106 | - } |
|
107 | - |
|
108 | - return Response::json( [], 200); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * Remove the specified resource from storage. |
|
114 | - * |
|
115 | - * @param int $id |
|
116 | - * @return Response |
|
117 | - */ |
|
118 | - public function destroy($id) |
|
119 | - { |
|
120 | - if( !$this->isID($id) ) |
|
121 | - return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400); |
|
122 | - |
|
123 | - $category = Categories::fromGroup()->find($id); |
|
12 | + /** |
|
13 | + * Display a listing of the resource. |
|
14 | + * |
|
15 | + * @return Response |
|
16 | + */ |
|
17 | + public function index() |
|
18 | + { |
|
19 | + $categoriesFromGroup = Categories::allAPI(); |
|
20 | + |
|
21 | + return Response::json( $categoriesFromGroup, 200); |
|
22 | + } |
|
23 | + |
|
24 | + /** |
|
25 | + * Store a newly created resource in storage. |
|
26 | + * |
|
27 | + * @return Response |
|
28 | + */ |
|
29 | + public function store() |
|
30 | + { |
|
31 | + $validator = Validator::make(Input::all(), [ |
|
32 | + 'title' => 'required|alpha|between:1,50', |
|
33 | + 'description' => '' |
|
34 | + ]); |
|
35 | + |
|
36 | + if( $validator->fails() ) { |
|
37 | + return Response::json( ['code'=>1, 'error'=>'Validation failed'], 400); |
|
38 | + } |
|
39 | + |
|
40 | + $category = new Categories(); |
|
41 | + $category->group_id = Session::get('groupID'); |
|
42 | + $category->category_title = Input::get('title'); |
|
43 | + $category->description = Input::get('description'); |
|
44 | + $category->is_active = true; |
|
45 | + |
|
46 | + if( !$category->save() ) { |
|
47 | + |
|
48 | + return Response::json( ['code'=>2, 'error'=>'Database error'], 400); |
|
49 | + } |
|
50 | + |
|
51 | + return Response::json( ['id' => DB::getPdo()->lastInsertId() ], 200); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Display the specified resource. |
|
57 | + * |
|
58 | + * @param int $id |
|
59 | + * @return Response |
|
60 | + */ |
|
61 | + public function show($id) |
|
62 | + { |
|
63 | + if( !$this->isID($id) ) |
|
64 | + return Response::json( ['code'=>1, 'error'=>'Parameter must be an integer'], 400); |
|
65 | + |
|
66 | + $category = Categories::fromGroup()->find($id); |
|
67 | + |
|
68 | + if( $category == null ) |
|
69 | + return Response::json(); |
|
70 | + |
|
71 | + return Response::json($category, 200); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * Update the specified resource in storage. |
|
77 | + * |
|
78 | + * @param int $id |
|
79 | + * @return Response |
|
80 | + */ |
|
81 | + public function update($id) |
|
82 | + { |
|
83 | + $validator = Validator::make(Input::all(), [ |
|
84 | + 'title' => 'required|alpha|between:1,50', |
|
85 | + 'description' => '' |
|
86 | + ]); |
|
87 | + |
|
88 | + if( $validator->fails() ) { |
|
89 | + return Response::json( ['code'=>3, 'error'=>'Validation failed'], 400); |
|
90 | + } |
|
91 | + |
|
92 | + if( !$this->isID($id) ) |
|
93 | + return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400); |
|
94 | + |
|
95 | + $category = Categories::fromGroup()->find($id); |
|
96 | + |
|
97 | + if( $category == null ) |
|
98 | + return Response::json( ['code'=>2, 'error'=>'Category not found'] , 400); |
|
99 | + |
|
100 | + $category->category_title = Input::get('title'); |
|
101 | + $category->description = Input::get('description'); |
|
102 | + |
|
103 | + if( !$category->save() ) { |
|
104 | + |
|
105 | + return Response::json( ['code'=>2, 'error'=>'Database error'], 400); |
|
106 | + } |
|
107 | + |
|
108 | + return Response::json( [], 200); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * Remove the specified resource from storage. |
|
114 | + * |
|
115 | + * @param int $id |
|
116 | + * @return Response |
|
117 | + */ |
|
118 | + public function destroy($id) |
|
119 | + { |
|
120 | + if( !$this->isID($id) ) |
|
121 | + return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400); |
|
122 | + |
|
123 | + $category = Categories::fromGroup()->find($id); |
|
124 | 124 | |
125 | - if( $category == null ) |
|
126 | - return Response::json( ['code'=>2, 'error'=>'Category not found'], 400); |
|
125 | + if( $category == null ) |
|
126 | + return Response::json( ['code'=>2, 'error'=>'Category not found'], 400); |
|
127 | 127 | |
128 | - $products = Categories::find($id)->products()->get(); |
|
128 | + $products = Categories::find($id)->products()->get(); |
|
129 | 129 | |
130 | - if( count($products) != 0 ) |
|
131 | - return Response::json( ['code'=>3, 'error'=>'Category not empty'], 400); |
|
130 | + if( count($products) != 0 ) |
|
131 | + return Response::json( ['code'=>3, 'error'=>'Category not empty'], 400); |
|
132 | 132 | |
133 | - try { |
|
134 | - $category->delete(); |
|
135 | - } |
|
136 | - catch(\Exception $e) { |
|
137 | - return Response::json( ['code'=>4, 'error'=>'Database error'], 400); |
|
138 | - } |
|
133 | + try { |
|
134 | + $category->delete(); |
|
135 | + } |
|
136 | + catch(\Exception $e) { |
|
137 | + return Response::json( ['code'=>4, 'error'=>'Database error'], 400); |
|
138 | + } |
|
139 | 139 | |
140 | - return Response::json( [], 200); |
|
141 | - } |
|
140 | + return Response::json( [], 200); |
|
141 | + } |
|
142 | 142 | |
143 | - private function isID($id) { |
|
143 | + private function isID($id) { |
|
144 | 144 | |
145 | - return (bool) preg_match('/^[0-9]{1,10}$/', $id); |
|
146 | - } |
|
145 | + return (bool) preg_match('/^[0-9]{1,10}$/', $id); |
|
146 | + } |
|
147 | 147 | } |
@@ -13,17 +13,17 @@ discard block |
||
13 | 13 | |
14 | 14 | class LoginController extends Controller { |
15 | 15 | |
16 | - private $userRepository; |
|
16 | + private $userRepository; |
|
17 | 17 | |
18 | - public function __construct(UserRepository $repository) |
|
19 | - { |
|
20 | - $this->userRepository = $repository; |
|
21 | - } |
|
18 | + public function __construct(UserRepository $repository) |
|
19 | + { |
|
20 | + $this->userRepository = $repository; |
|
21 | + } |
|
22 | 22 | |
23 | - public function getLoginForm() |
|
24 | - { |
|
25 | - return view('public.login'); |
|
26 | - } |
|
23 | + public function getLoginForm() |
|
24 | + { |
|
25 | + return view('public.login'); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | public function loginAttempt(Request $request) |
29 | 29 | { |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | |
44 | 44 | try |
45 | 45 | { |
46 | - $user = $this->userRepository->findActive($email); |
|
46 | + $user = $this->userRepository->findActive($email); |
|
47 | 47 | } |
48 | 48 | catch (RepositoryException $e) |
49 | 49 | { |
50 | - return redirect('/')->with('error', 'The email and password you entered don\'t match') |
|
50 | + return redirect('/')->with('error', 'The email and password you entered don\'t match') |
|
51 | 51 | ->with('email', $email); |
52 | 52 | } |
53 | 53 |
@@ -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 | } |
@@ -8,35 +8,35 @@ |
||
8 | 8 | |
9 | 9 | class SnapshotController extends \Controller { |
10 | 10 | |
11 | - protected $repository; |
|
12 | - |
|
13 | - public function __construct(SnapshotRepository $repository) |
|
14 | - { |
|
15 | - $this->repository = $repository; |
|
16 | - } |
|
17 | - |
|
18 | - public function index() |
|
19 | - { |
|
20 | - $snapshots = $this->repository->all(); |
|
21 | - return Response::json( $this->repository->APIFormat($snapshots), 200); |
|
22 | - } |
|
23 | - |
|
24 | - public function store() |
|
25 | - { |
|
26 | - $snapshot = $this->repository->store( Input::all() ); |
|
27 | - return Response::json( ['id' => $snapshot->id], 200); |
|
28 | - } |
|
29 | - |
|
30 | - public function show($id) |
|
31 | - { |
|
32 | - $snapshot = $this->repository->get($id); |
|
33 | - return Response::json($this->repository->APIFormat($snapshot), 200); |
|
34 | - } |
|
35 | - |
|
36 | - public function getCurrent() |
|
37 | - { |
|
38 | - $snapshot = $this->repository->current(); |
|
39 | - return Response::json($this->repository->APIFormat($snapshot), 200); |
|
40 | - } |
|
11 | + protected $repository; |
|
12 | + |
|
13 | + public function __construct(SnapshotRepository $repository) |
|
14 | + { |
|
15 | + $this->repository = $repository; |
|
16 | + } |
|
17 | + |
|
18 | + public function index() |
|
19 | + { |
|
20 | + $snapshots = $this->repository->all(); |
|
21 | + return Response::json( $this->repository->APIFormat($snapshots), 200); |
|
22 | + } |
|
23 | + |
|
24 | + public function store() |
|
25 | + { |
|
26 | + $snapshot = $this->repository->store( Input::all() ); |
|
27 | + return Response::json( ['id' => $snapshot->id], 200); |
|
28 | + } |
|
29 | + |
|
30 | + public function show($id) |
|
31 | + { |
|
32 | + $snapshot = $this->repository->get($id); |
|
33 | + return Response::json($this->repository->APIFormat($snapshot), 200); |
|
34 | + } |
|
35 | + |
|
36 | + public function getCurrent() |
|
37 | + { |
|
38 | + $snapshot = $this->repository->current(); |
|
39 | + return Response::json($this->repository->APIFormat($snapshot), 200); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
@@ -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() |
@@ -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 | } |