Completed
Push — master ( 2f51b9...5a5df7 )
by Corentin
23:21
created
app/Http/Controllers/CategoryController.php 4 patches
Doc Comments   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	/**
13 13
 	 * Display a listing of the resource.
14 14
 	 *
15
-	 * @return Response
15
+	 * @return \Illuminate\Http\JsonResponse
16 16
 	 */
17 17
 	public function index()
18 18
 	{
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * Store a newly created resource in storage.
26 26
 	 *
27
-	 * @return Response
27
+	 * @return \Illuminate\Http\JsonResponse
28 28
 	 */
29 29
 	public function store()
30 30
 	{		
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * Display the specified resource.
57 57
 	 *
58 58
 	 * @param  int  $id
59
-	 * @return Response
59
+	 * @return \Illuminate\Http\JsonResponse
60 60
 	 */
61 61
 	public function show($id)
62 62
 	{
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * Update the specified resource in storage.
77 77
 	 *
78 78
 	 * @param  int  $id
79
-	 * @return Response
79
+	 * @return \Illuminate\Http\JsonResponse
80 80
 	 */
81 81
 	public function update($id)
82 82
 	{
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * Remove the specified resource from storage.
114 114
 	 *
115 115
 	 * @param  int  $id
116
-	 * @return Response
116
+	 * @return \Illuminate\Http\JsonResponse
117 117
 	 */
118 118
 	public function destroy($id)
119 119
 	{
@@ -140,6 +140,9 @@  discard block
 block discarded – undo
140 140
     	return Response::json( [], 200);
141 141
 	}
142 142
 
143
+	/**
144
+	 * @param integer $id
145
+	 */
143 146
 	private function isID($id) {
144 147
 
145 148
 		return (bool) preg_match('/^[0-9]{1,10}$/', $id);
Please login to merge, or discard this patch.
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -9,139 +9,139 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 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
 		$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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this 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/InstallController.php 2 patches
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -2,9 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
-use App\Http\Requests;
6 5
 use App\User;
7
-use Config;
8 6
 use DateTimeZone;
9 7
 use Exception;
10 8
 use Hash;
@@ -12,8 +10,6 @@  discard block
 block discarded – undo
12 10
 use Illuminate\Support\Facades\Artisan;
13 11
 use PDO;
14 12
 use PDOException;
15
-use Session;
16
-use URL;
17 13
 
18 14
 class InstallController extends Controller
19 15
 {
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
app/Http/Controllers/SnapshotController.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use App\Exceptions\RepositoryException;
4
-use App\Repositories\SnapshotDetailsRepository;
5 3
 use App\Repositories\SnapshotRepository;
6 4
 use Input;
7 5
 use Response;
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
app/Repositories/UserRepository.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -28,6 +28,9 @@  discard block
 block discarded – undo
28 28
         }
29 29
     }
30 30
 
31
+    /**
32
+     * @param boolean $isActive
33
+     */
31 34
     public function allByStatus($isActive)
32 35
     {
33 36
         if (!is_bool($isActive)) {
@@ -98,6 +101,9 @@  discard block
 block discarded – undo
98 101
         return $user;
99 102
     }
100 103
 
104
+    /**
105
+     * @return string|null
106
+     */
101 107
     public function changeRole($userId)
102 108
     {
103 109
         $user = $this->get($userId);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -213,7 +213,7 @@
 block discarded – undo
213 213
             $user->delete();
214 214
         } catch (Exception $e) {
215 215
 
216
-            throw new RepositoryException('Database error #' . $e->getCode(), RepositoryException::DATABASE_ERROR);
216
+            throw new RepositoryException('Database error #'.$e->getCode(), RepositoryException::DATABASE_ERROR);
217 217
         }
218 218
 
219 219
         return $user;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -206,8 +206,9 @@
 block discarded – undo
206 206
     {
207 207
         $user = $this->get($userId);
208 208
 
209
-        if ($user->role == 'ADMN')
210
-            throw new RepositoryException('Cannot delete administrator', RepositoryException::RESOURCE_DENIED);
209
+        if ($user->role == 'ADMN') {
210
+                    throw new RepositoryException('Cannot delete administrator', RepositoryException::RESOURCE_DENIED);
211
+        }
211 212
 
212 213
         try {
213 214
             $user->delete();
Please login to merge, or discard this patch.
app/Console/Commands/DatabaseFaker.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
app/Console/Commands/Inspire.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -5,28 +5,28 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
app/Console/Kernel.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -5,26 +5,26 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
app/Http/Controllers/AccountController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@
 block discarded – undo
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
 
Please login to merge, or discard this 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 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) . '&euro; from drawer' : 'added ' . $amount . '&euro; in drawer';
172
-        return Redirect::to('app/cash')->with('success', 'Cash operation saved: ' . $message);
171
+        $message = ($amount<0) ? 'removed '.abs($amount).'&euro; from drawer' : 'added '.$amount.'&euro; 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
 block discarded – undo
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
 block discarded – undo
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");
Please login to merge, or discard this 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.