Completed
Push — master ( 2f51b9...5a5df7 )
by Corentin
23:21
created
app/Http/Controllers/AccountController.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,11 +33,9 @@
 block discarded – undo
33 33
     {
34 34
         try {
35 35
             $this->userRepository->updateAccount(auth()->id(), $request->all());
36
-        }
37
-        catch(ValidationException $e) {
36
+        } catch(ValidationException $e) {
38 37
             return redirect('app/account')->with('error', $e->getMessageBag()->first());
39
-        }
40
-        catch(RepositoryException $e) {
38
+        } catch(RepositoryException $e) {
41 39
             return redirect('app/account')->with('error', 'Could not update settings: '.strtolower($e->getMessage()));
42 40
         }
43 41
 
Please login to merge, or discard this patch.
app/Http/Controllers/CashController.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,9 +25,11 @@
 block discarded – undo
25 25
 
26 26
     public function dashboard($requestedSnapshot = null)
27 27
     {
28
-        if (isset($requestedSnapshot))     // Search snapshot in history
28
+        if (isset($requestedSnapshot)) {
29
+            // Search snapshot in history
29 30
         {
30 31
             $snapshot = $this->snapshotRepository->get($requestedSnapshot);
32
+        }
31 33
         } else    // Grab the current snapshot, or redirect if no one exists
32 34
         {
33 35
             try {
Please login to merge, or discard this patch.
app/Http/Controllers/CategoryController.php 1 patch
Braces   +22 added lines, -16 removed lines patch added patch discarded remove patch
@@ -60,13 +60,15 @@  discard block
 block discarded – undo
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 67
 		$category = Categories::fromGroup()->find($id);
67 68
 
68
-		if( $category == null )
69
-			return Response::json();
69
+		if( $category == null ) {
70
+					return Response::json();
71
+		}
70 72
 
71 73
 		return Response::json($category, 200);
72 74
 	}
@@ -89,13 +91,15 @@  discard block
 block discarded – undo
89 91
     		return Response::json( ['code'=>3, 'error'=>'Validation failed'], 400);
90 92
     	}
91 93
 
92
-		if( !$this->isID($id) )
93
-			return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400);
94
+		if( !$this->isID($id) ) {
95
+					return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400);
96
+		}
94 97
 
95 98
 		$category = Categories::fromGroup()->find($id);
96 99
 
97
-		if( $category == null )
98
-			return Response::json( ['code'=>2, 'error'=>'Category not found'] , 400);
100
+		if( $category == null ) {
101
+					return Response::json( ['code'=>2, 'error'=>'Category not found'] , 400);
102
+		}
99 103
 
100 104
 		$category->category_title = Input::get('title');
101 105
 		$category->description = Input::get('description');
@@ -117,23 +121,25 @@  discard block
 block discarded – undo
117 121
 	 */
118 122
 	public function destroy($id)
119 123
 	{
120
-		if( !$this->isID($id) )
121
-			return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400);
124
+		if( !$this->isID($id) ) {
125
+					return Response::json(['code'=>1, 'error'=>'Parameter must be numeric'], 400);
126
+		}
122 127
 
123 128
 		$category = Categories::fromGroup()->find($id);
124 129
 		
125
-		if( $category == null )
126
-			return Response::json( ['code'=>2, 'error'=>'Category not found'], 400);
130
+		if( $category == null ) {
131
+					return Response::json( ['code'=>2, 'error'=>'Category not found'], 400);
132
+		}
127 133
 
128 134
 		$products = Categories::find($id)->products()->get();
129 135
 
130
-		if( count($products) != 0 )
131
-			return Response::json( ['code'=>3, 'error'=>'Category not empty'], 400);
136
+		if( count($products) != 0 ) {
137
+					return Response::json( ['code'=>3, 'error'=>'Category not empty'], 400);
138
+		}
132 139
 
133 140
 		try {
134 141
 			$category->delete();
135
-		}
136
-		catch(\Exception $e) {
142
+		} catch(\Exception $e) {
137 143
 			return Response::json( ['code'=>4, 'error'=>'Database error'], 400);
138 144
 		}
139 145
 
Please login to merge, or discard this patch.
app/Http/Controllers/LoginController.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@
 block discarded – undo
44 44
         try 
45 45
         {
46 46
         	$user = $this->userRepository->findActive($email);
47
-        }
48
-        catch (RepositoryException $e)
47
+        } catch (RepositoryException $e)
49 48
         {
50 49
         	return redirect('/')->with('error', 'The email and password you entered don\'t match')
51 50
                                 ->with('email', $email);
Please login to merge, or discard this patch.
app/Http/Controllers/StatsController.php 1 patch
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
app/Http/Controllers/UsersController.php 1 patch
Braces   +13 added lines, -16 removed lines patch added patch discarded remove patch
@@ -57,12 +57,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     	
Please login to merge, or discard this patch.
app/Http/Middleware/Authenticate.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@
 block discarded – undo
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
 			}
Please login to merge, or discard this patch.
app/Http/Middleware/User.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
app/Models/Products.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@
 block discarded – undo
46 46
 
47 47
 		$products = DB::select($query, [ Session::get('groupID'), $id ]);
48 48
 
49
-		if( count($products) == 0 )
50
-			return null;
49
+		if( count($products) == 0 ) {
50
+					return null;
51
+		}
51 52
 
52 53
 		return $products[0];
53 54
 	}
Please login to merge, or discard this patch.