@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $this->info('This command will truncate all your Barmate data.'); |
34 | 34 | $this->info("Use this command only for testing purposes.\n"); |
35 | 35 | |
36 | - if( $this->confirm('Are you sure you want to continue? ', false)==false ) |
|
36 | + if ($this->confirm('Are you sure you want to continue? ', false) == false) |
|
37 | 37 | { |
38 | 38 | $this->info('Command aborted'); |
39 | 39 | return 1; |
@@ -62,20 +62,20 @@ discard block |
||
62 | 62 | |
63 | 63 | private function seedUsers($groupId) |
64 | 64 | { |
65 | - for($i=0; $i<self::NB_USERS; $i++) |
|
65 | + for ($i = 0; $i<self::NB_USERS; $i++) |
|
66 | 66 | { |
67 | 67 | $firstName = $this->faker->firstName; |
68 | 68 | $lastName = $this->faker->lastName; |
69 | 69 | $email = strtolower($firstName.'.'.$lastName.'@'.$this->faker->domainName); |
70 | 70 | |
71 | - User::create([ 'firstname' => $firstName, |
|
71 | + User::create(['firstname' => $firstName, |
|
72 | 72 | 'lastname' => $lastName, |
73 | 73 | 'group_id' => $groupId, |
74 | 74 | 'email' => $email, |
75 | 75 | 'password_hash' => Hash::make('password'), |
76 | - 'role' => ( $i%2 == 0 ) ? 'USER' : 'MNGR', |
|
76 | + 'role' => ($i % 2 == 0) ? 'USER' : 'MNGR', |
|
77 | 77 | 'inscription_date' => $this->faker->dateTime, |
78 | - 'is_active' => ( $i%5 == 0 ) ? false : true ]); |
|
78 | + 'is_active' => ($i % 5 == 0) ? false : true]); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $this->info('Added '.self::NB_USERS.' users to the application with password \'password\'.'); |
@@ -88,20 +88,20 @@ discard block |
||
88 | 88 | $categories = ['Saison', 'Gueuze', 'Tripel', 'Witbier', 'Dubbel']; |
89 | 89 | shuffle($categories); |
90 | 90 | |
91 | - foreach($categories as $categoryName) |
|
91 | + foreach ($categories as $categoryName) |
|
92 | 92 | { |
93 | 93 | $category = Categories::create(['group_id' => $groupId, |
94 | 94 | 'category_title' => $categoryName]); |
95 | 95 | |
96 | 96 | $nbProducts = rand(1, self::MAX_NB_PRODUCTS); |
97 | 97 | |
98 | - for($i=1; $i<=$nbProducts; $i++) |
|
98 | + for ($i = 1; $i<=$nbProducts; $i++) |
|
99 | 99 | { |
100 | 100 | Products::create(['category_id' => $category->category_id, |
101 | 101 | 'product_name' => $categoryName.''.$i, |
102 | 102 | 'description' => '', |
103 | 103 | 'price' => rand(1, 4), |
104 | - 'quantity' => rand(24,48)]); |
|
104 | + 'quantity' => rand(24, 48)]); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 |
@@ -34,10 +34,10 @@ |
||
34 | 34 | try { |
35 | 35 | $this->userRepository->updateAccount(auth()->id(), $request->all()); |
36 | 36 | } |
37 | - catch(ValidationException $e) { |
|
37 | + catch (ValidationException $e) { |
|
38 | 38 | return redirect('app/account')->with('error', $e->getMessageBag()->first()); |
39 | 39 | } |
40 | - catch(RepositoryException $e) { |
|
40 | + catch (RepositoryException $e) { |
|
41 | 41 | return redirect('app/account')->with('error', 'Could not update settings: '.strtolower($e->getMessage())); |
42 | 42 | } |
43 | 43 |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | private function approximateDuration(Carbon $oldSnapshotTime, Carbon $nextSnapshotTime) |
118 | 118 | { |
119 | 119 | $years = $oldSnapshotTime->diffInYears($nextSnapshotTime); |
120 | - if( $years > 0 ) { |
|
120 | + if ($years>0) { |
|
121 | 121 | return ($years == 1) ? "1 year" : "$years years"; |
122 | 122 | } |
123 | 123 | |
124 | 124 | $months = $oldSnapshotTime->diffInMonths($nextSnapshotTime); |
125 | - if($months > 0 ) { |
|
125 | + if ($months>0) { |
|
126 | 126 | return ($months == 1) ? "1 month" : "$months months"; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $days = $oldSnapshotTime->diffInDays($nextSnapshotTime); |
130 | - if ($days > 0) { |
|
130 | + if ($days>0) { |
|
131 | 131 | return ($days == 1) ? "1 day" : "$days days"; |
132 | 132 | } |
133 | 133 | |
134 | 134 | $hours = $oldSnapshotTime->diffInHours($nextSnapshotTime); |
135 | - if ($hours > 0) { |
|
135 | + if ($hours>0) { |
|
136 | 136 | return ($hours == 1) ? "1 hour" : "$hours hours"; |
137 | 137 | } |
138 | 138 | |
139 | 139 | $minutes = $oldSnapshotTime->diffInMinutes($nextSnapshotTime); |
140 | - if($minutes > 0) { |
|
140 | + if ($minutes>0) { |
|
141 | 141 | return ($minutes == 1) ? "1 minute" : "$minutes minutes"; |
142 | 142 | } |
143 | 143 | |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $this->detailsRepository->store($operationData); |
166 | 166 | } catch (RepositoryException $e) { |
167 | - return Redirect::to('app/cash/register-operation')->with('error', 'Could not save operation: ' . $e->getMessage()) |
|
167 | + return Redirect::to('app/cash/register-operation')->with('error', 'Could not save operation: '.$e->getMessage()) |
|
168 | 168 | ->withInput(); |
169 | 169 | } |
170 | 170 | |
171 | - $message = ($amount < 0) ? 'removed ' . abs($amount) . '€ from drawer' : 'added ' . $amount . '€ in drawer'; |
|
172 | - return Redirect::to('app/cash')->with('success', 'Cash operation saved: ' . $message); |
|
171 | + $message = ($amount<0) ? 'removed '.abs($amount).'€ from drawer' : 'added '.$amount.'€ in drawer'; |
|
172 | + return Redirect::to('app/cash')->with('success', 'Cash operation saved: '.$message); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | public function snapshotForm() |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | try { |
185 | 185 | $this->snapshotRepository->store(Input::all()); |
186 | 186 | } catch (RepositoryException $e) { |
187 | - return Redirect::to('app/cash/new-snapshot')->with('error', 'Error while creating snapshot: ' . $e->getMessage()) |
|
187 | + return Redirect::to('app/cash/new-snapshot')->with('error', 'Error while creating snapshot: '.$e->getMessage()) |
|
188 | 188 | ->withInput(); |
189 | 189 | } |
190 | 190 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | DB::commit(); |
216 | 216 | |
217 | 217 | } catch (RepositoryException $e) { |
218 | - return redirect('app/cash')->with('error', 'An error occurred: ' . strtolower($e->getMessage())); |
|
218 | + return redirect('app/cash')->with('error', 'An error occurred: '.strtolower($e->getMessage())); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return redirect('app/cash')->with('success', "Snapshot item removed"); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | { |
19 | 19 | $categoriesFromGroup = Categories::allAPI(); |
20 | 20 | |
21 | - return Response::json( $categoriesFromGroup, 200); |
|
21 | + return Response::json($categoriesFromGroup, 200); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | 'description' => '' |
34 | 34 | ]); |
35 | 35 | |
36 | - if( $validator->fails() ) { |
|
37 | - return Response::json( ['code'=>1, 'error'=>'Validation failed'], 400); |
|
36 | + if ($validator->fails()) { |
|
37 | + return Response::json(['code'=>1, 'error'=>'Validation failed'], 400); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $category = new Categories(); |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | $category->description = Input::get('description'); |
44 | 44 | $category->is_active = true; |
45 | 45 | |
46 | - if( !$category->save() ) { |
|
46 | + if (!$category->save()) { |
|
47 | 47 | |
48 | - return Response::json( ['code'=>2, 'error'=>'Database error'], 400); |
|
48 | + return Response::json(['code'=>2, 'error'=>'Database error'], 400); |
|
49 | 49 | } |
50 | 50 | |
51 | - return Response::json( ['id' => DB::getPdo()->lastInsertId() ], 200); |
|
51 | + return Response::json(['id' => DB::getPdo()->lastInsertId()], 200); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function show($id) |
62 | 62 | { |
63 | - if( !$this->isID($id) ) |
|
64 | - return Response::json( ['code'=>1, 'error'=>'Parameter must be an integer'], 400); |
|
63 | + if (!$this->isID($id)) |
|
64 | + return Response::json(['code'=>1, 'error'=>'Parameter must be an integer'], 400); |
|
65 | 65 | |
66 | 66 | $category = Categories::fromGroup()->find($id); |
67 | 67 | |
68 | - if( $category == null ) |
|
68 | + if ($category == null) |
|
69 | 69 | return Response::json(); |
70 | 70 | |
71 | 71 | return Response::json($category, 200); |
@@ -85,27 +85,27 @@ discard block |
||
85 | 85 | 'description' => '' |
86 | 86 | ]); |
87 | 87 | |
88 | - if( $validator->fails() ) { |
|
89 | - return Response::json( ['code'=>3, 'error'=>'Validation failed'], 400); |
|
88 | + if ($validator->fails()) { |
|
89 | + return Response::json(['code'=>3, 'error'=>'Validation failed'], 400); |
|
90 | 90 | } |
91 | 91 | |
92 | - if( !$this->isID($id) ) |
|
92 | + if (!$this->isID($id)) |
|
93 | 93 | return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400); |
94 | 94 | |
95 | 95 | $category = Categories::fromGroup()->find($id); |
96 | 96 | |
97 | - if( $category == null ) |
|
98 | - return Response::json( ['code'=>2, 'error'=>'Category not found'] , 400); |
|
97 | + if ($category == null) |
|
98 | + return Response::json(['code'=>2, 'error'=>'Category not found'], 400); |
|
99 | 99 | |
100 | 100 | $category->category_title = Input::get('title'); |
101 | 101 | $category->description = Input::get('description'); |
102 | 102 | |
103 | - if( !$category->save() ) { |
|
103 | + if (!$category->save()) { |
|
104 | 104 | |
105 | - return Response::json( ['code'=>2, 'error'=>'Database error'], 400); |
|
105 | + return Response::json(['code'=>2, 'error'=>'Database error'], 400); |
|
106 | 106 | } |
107 | 107 | |
108 | - return Response::json( [], 200); |
|
108 | + return Response::json([], 200); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function destroy($id) |
119 | 119 | { |
120 | - if( !$this->isID($id) ) |
|
120 | + if (!$this->isID($id)) |
|
121 | 121 | return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400); |
122 | 122 | |
123 | 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 | 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 | 133 | try { |
134 | 134 | $category->delete(); |
135 | 135 | } |
136 | - catch(\Exception $e) { |
|
137 | - return Response::json( ['code'=>4, 'error'=>'Database error'], 400); |
|
136 | + catch (\Exception $e) { |
|
137 | + return Response::json(['code'=>4, 'error'=>'Database error'], 400); |
|
138 | 138 | } |
139 | 139 | |
140 | - return Response::json( [], 200); |
|
140 | + return Response::json([], 200); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | private function isID($id) { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'TOKENIZER_EXTENSION' => false, |
38 | 38 | 'WRITE_ACCESS' => false]; |
39 | 39 | |
40 | - if ($this->getPhpVersionId() >= self::REQUIRED_PHP_VERSION_ID) { |
|
40 | + if ($this->getPhpVersionId()>=self::REQUIRED_PHP_VERSION_ID) { |
|
41 | 41 | $requirements['PHP_VERSION'] = true; |
42 | 42 | } |
43 | 43 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | public function checkEnvironmentFile(Request $request) |
144 | 144 | { |
145 | - if (file_exists(base_path() . '/.env')) { |
|
145 | + if (file_exists(base_path().'/.env')) { |
|
146 | 146 | return redirect('install/account'); |
147 | 147 | } |
148 | 148 | |
@@ -174,34 +174,34 @@ discard block |
||
174 | 174 | { |
175 | 175 | $configArray = session(self::CONFIG_KEY); |
176 | 176 | |
177 | - $configContent = 'APP_ENV=production' . PHP_EOL; |
|
178 | - $configContent .= 'APP_DEBUG=false' . PHP_EOL; |
|
179 | - $configContent .= 'APP_URL=' . $configArray['app_url'] . '' . PHP_EOL; |
|
180 | - $configContent .= 'APP_KEY=' . $configArray['app_key'] . '' . PHP_EOL; |
|
181 | - $configContent .= 'APP_TIMEZONE=' . $configArray['app_timezone'] . '' . PHP_EOL; |
|
177 | + $configContent = 'APP_ENV=production'.PHP_EOL; |
|
178 | + $configContent .= 'APP_DEBUG=false'.PHP_EOL; |
|
179 | + $configContent .= 'APP_URL='.$configArray['app_url'].''.PHP_EOL; |
|
180 | + $configContent .= 'APP_KEY='.$configArray['app_key'].''.PHP_EOL; |
|
181 | + $configContent .= 'APP_TIMEZONE='.$configArray['app_timezone'].''.PHP_EOL; |
|
182 | 182 | |
183 | - $configContent .= 'DB_DRIVER=mysql' . PHP_EOL; |
|
184 | - $configContent .= 'DB_HOST=' . $configArray['db_hostname'] . '' . PHP_EOL; |
|
185 | - $configContent .= 'DB_DATABASE=' . $configArray['db_name'] . '' . PHP_EOL; |
|
186 | - $configContent .= 'DB_USERNAME=' . $configArray['db_username'] . '' . PHP_EOL; |
|
187 | - $configContent .= 'DB_PASSWORD=' . $configArray['db_password'] . '' . PHP_EOL; |
|
183 | + $configContent .= 'DB_DRIVER=mysql'.PHP_EOL; |
|
184 | + $configContent .= 'DB_HOST='.$configArray['db_hostname'].''.PHP_EOL; |
|
185 | + $configContent .= 'DB_DATABASE='.$configArray['db_name'].''.PHP_EOL; |
|
186 | + $configContent .= 'DB_USERNAME='.$configArray['db_username'].''.PHP_EOL; |
|
187 | + $configContent .= 'DB_PASSWORD='.$configArray['db_password'].''.PHP_EOL; |
|
188 | 188 | |
189 | - $configContent .= 'MAIL_DRIVER=smtp' . PHP_EOL; |
|
190 | - $configContent .= 'MAIL_HOST=mailtrap.io' . PHP_EOL; |
|
191 | - $configContent .= 'MAIL_PORT=2525' . PHP_EOL; |
|
192 | - $configContent .= 'MAIL_USERNAME=null' . PHP_EOL; |
|
193 | - $configContent .= 'MAIL_PASSWORD=null' . PHP_EOL; |
|
189 | + $configContent .= 'MAIL_DRIVER=smtp'.PHP_EOL; |
|
190 | + $configContent .= 'MAIL_HOST=mailtrap.io'.PHP_EOL; |
|
191 | + $configContent .= 'MAIL_PORT=2525'.PHP_EOL; |
|
192 | + $configContent .= 'MAIL_USERNAME=null'.PHP_EOL; |
|
193 | + $configContent .= 'MAIL_PASSWORD=null'.PHP_EOL; |
|
194 | 194 | |
195 | - $configContent .= 'CACHE_DRIVER=file' . PHP_EOL; |
|
196 | - $configContent .= 'SESSION_DRIVER=file' . PHP_EOL; |
|
197 | - $configContent .= 'QUEUE_DRIVER=sync' . PHP_EOL; |
|
195 | + $configContent .= 'CACHE_DRIVER=file'.PHP_EOL; |
|
196 | + $configContent .= 'SESSION_DRIVER=file'.PHP_EOL; |
|
197 | + $configContent .= 'QUEUE_DRIVER=sync'.PHP_EOL; |
|
198 | 198 | |
199 | 199 | |
200 | 200 | if (!is_writable(base_path())) { |
201 | 201 | throw new Exception('Could not create the configuration file'); |
202 | 202 | } |
203 | 203 | |
204 | - $fileHandle = fopen(base_path() . '/.env', "w"); |
|
204 | + $fileHandle = fopen(base_path().'/.env', "w"); |
|
205 | 205 | fwrite($fileHandle, $configContent); |
206 | 206 | fclose($fileHandle); |
207 | 207 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $request->session()->forget(self::CONFIG_KEY); |
212 | 212 | |
213 | 213 | try { |
214 | - unlink(base_path() . '/' . self::INSTALLATION_FILE); |
|
214 | + unlink(base_path().'/'.self::INSTALLATION_FILE); |
|
215 | 215 | return view('install.finished'); |
216 | 216 | } catch (\ErrorException $e) { |
217 | 217 | return view('install.finished')->with('lockError', true); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | private function hasDatabaseAccess($hostname, $username, $password, $database) |
232 | 232 | { |
233 | 233 | try { |
234 | - (new PDO("mysql:host=$hostname;dbname=$database", $username, $password))->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);; |
|
234 | + (new PDO("mysql:host=$hostname;dbname=$database", $username, $password))->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); ; |
|
235 | 235 | } catch (PDOException $e) { |
236 | 236 | return false; |
237 | 237 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | $email = $request->input('email'); |
37 | 37 | |
38 | - if( $validator->fails() ) |
|
38 | + if ($validator->fails()) |
|
39 | 39 | { |
40 | 40 | return redirect('/')->with('error', 'Your credentials have an invalid format') |
41 | 41 | ->with('email', $email); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | ->with('email', $email); |
52 | 52 | } |
53 | 53 | |
54 | - if( !Hash::check(Input::get('password'), $user->password_hash) ) |
|
54 | + if (!Hash::check(Input::get('password'), $user->password_hash)) |
|
55 | 55 | { |
56 | 56 | return redirect('/')->with('error', 'The email and password you entered don\'t match') |
57 | 57 | ->with('email', $email); |
@@ -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); |
@@ -18,13 +18,13 @@ |
||
18 | 18 | public function index() |
19 | 19 | { |
20 | 20 | $snapshots = $this->repository->all(); |
21 | - return Response::json( $this->repository->APIFormat($snapshots), 200); |
|
21 | + return Response::json($this->repository->APIFormat($snapshots), 200); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function store() |
25 | 25 | { |
26 | - $snapshot = $this->repository->store( Input::all() ); |
|
27 | - return Response::json( ['id' => $snapshot->id], 200); |
|
26 | + $snapshot = $this->repository->store(Input::all()); |
|
27 | + return Response::json(['id' => $snapshot->id], 200); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function show($id) |
@@ -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(); |