Passed
Push — master ( 3be567...10f746 )
by Ferry
03:51
created
src/helpers/Module.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
     {
26 26
         $routeArray = request()->route()->getAction();
27 27
         $this->controller = class_basename($routeArray['controller']);
28
-        $this->controller = strtok($this->controller,"@");
28
+        $this->controller = strtok($this->controller, "@");
29 29
 
30 30
         $className = "\\".$routeArray["namespace"]."\\".$this->controller;
31
-        if(class_exists($className)) {
32
-            $this->module = cb()->find("cb_modules",["controller"=>$this->controller]);
33
-            if($this->module) {
31
+        if (class_exists($className)) {
32
+            $this->module = cb()->find("cb_modules", ["controller"=>$this->controller]);
33
+            if ($this->module) {
34 34
                 $this->controller_class = new $className();
35
-                $this->menu = cb()->find("cb_menus",["cb_modules_id"=>$this->module->id]);
36
-                $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu;
37
-                if($this->menu) {
35
+                $this->menu = cb()->find("cb_menus", ["cb_modules_id"=>$this->module->id]);
36
+                $this->menu = (!$this->menu) ?cb()->find("cb_menus", ["type"=>"path", "path"=>request()->segment(2)]) : $this->menu;
37
+                if ($this->menu) {
38 38
                     $this->privilege = DB::table("cb_role_privileges")
39 39
                         ->where("cb_menus_id", $this->menu->id)
40 40
                         ->where("cb_roles_id", cb()->session()->roleId())
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
     public function getData($key) {
56
-        if($this->controller_class) {
56
+        if ($this->controller_class) {
57 57
             $value = $this->controller_class->getData($key);
58
-            if(isset($value)) {
58
+            if (isset($value)) {
59 59
                 return $value;
60 60
             }
61 61
         }
@@ -66,128 +66,128 @@  discard block
 block discarded – undo
66 66
      * @return CBController
67 67
      */
68 68
     public function getController() {
69
-        return ($this->controller_class)?$this->controller_class:null;
69
+        return ($this->controller_class) ? $this->controller_class : null;
70 70
     }
71 71
 
72 72
     public function getPageTitle()
73 73
     {
74
-        return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null;
74
+        return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null;
75 75
     }
76 76
 
77 77
     public function getTable()
78 78
     {
79
-        return ($this->controller_class)?$this->controller_class->getData("table"):null;
79
+        return ($this->controller_class) ? $this->controller_class->getData("table") : null;
80 80
     }
81 81
 
82 82
     public function getPageIcon()
83 83
     {
84
-        return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null;
84
+        return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null;
85 85
     }
86 86
 
87 87
     public function canBrowse() {
88
-        if($this->privilege) {
89
-            if($this->privilege->can_browse) return true;
88
+        if ($this->privilege) {
89
+            if ($this->privilege->can_browse) return true;
90 90
             else return false;
91
-        }else{
91
+        } else {
92 92
             return true;
93 93
         }
94 94
     }
95 95
 
96 96
     public function canCreate() {
97
-        if($this->privilege) {
98
-            if($this->privilege->can_create) return true;
97
+        if ($this->privilege) {
98
+            if ($this->privilege->can_create) return true;
99 99
             else return false;
100
-        }else{
100
+        } else {
101 101
             return true;
102 102
         }
103 103
     }
104 104
 
105 105
     public function canRead() {
106
-        if($this->privilege) {
107
-            if($this->privilege->can_read) return true;
106
+        if ($this->privilege) {
107
+            if ($this->privilege->can_read) return true;
108 108
             else return false;
109
-        }else{
109
+        } else {
110 110
             return true;
111 111
         }
112 112
     }
113 113
 
114 114
     public function canUpdate() {
115
-        if($this->privilege) {
116
-            if($this->privilege->can_update) return true;
115
+        if ($this->privilege) {
116
+            if ($this->privilege->can_update) return true;
117 117
             else return false;
118
-        }else{
118
+        } else {
119 119
             return true;
120 120
         }
121 121
     }
122 122
 
123 123
     public function canDelete() {
124
-        if($this->privilege) {
125
-            if($this->privilege->can_delete) return true;
124
+        if ($this->privilege) {
125
+            if ($this->privilege->can_delete) return true;
126 126
             else return false;
127
-        }else{
127
+        } else {
128 128
             return true;
129 129
         }
130 130
     }
131 131
 
132 132
     public function addURL()
133 133
     {
134
-        if($this->controller_class && method_exists($this->controller_class, 'getAdd')) {
134
+        if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) {
135 135
             return action($this->controller.'@getAdd');
136
-        }else{
136
+        } else {
137 137
             return null;
138 138
         }
139 139
     }
140 140
 
141 141
     public function addSaveURL()
142 142
     {
143
-        if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) {
143
+        if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) {
144 144
             return action($this->controller.'@postAddSave');
145
-        }else{
145
+        } else {
146 146
             return null;
147 147
         }
148 148
     }
149 149
 
150 150
     public function editURL($id = null)
151 151
     {
152
-        if($this->controller_class && method_exists($this->controller_class, 'getEdit')) {
153
-            return action($this->controller.'@getEdit',['id'=>$id]);
154
-        }else{
152
+        if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) {
153
+            return action($this->controller.'@getEdit', ['id'=>$id]);
154
+        } else {
155 155
             return null;
156 156
         }
157 157
     }
158 158
 
159 159
     public function editSaveURL($id = null)
160 160
     {
161
-        if(method_exists($this->controller_class, 'postEditSave')) {
162
-            return action($this->controller.'@postEditSave',['id'=>$id]);
163
-        }else{
161
+        if (method_exists($this->controller_class, 'postEditSave')) {
162
+            return action($this->controller.'@postEditSave', ['id'=>$id]);
163
+        } else {
164 164
             return null;
165 165
         }
166 166
     }
167 167
 
168
-    public function detailURL($id=null)
168
+    public function detailURL($id = null)
169 169
     {
170
-        if($this->controller_class && method_exists($this->controller_class, 'getDetail')) {
171
-            return action($this->controller.'@getDetail',['id'=>$id]);
172
-        }else{
170
+        if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) {
171
+            return action($this->controller.'@getDetail', ['id'=>$id]);
172
+        } else {
173 173
             return null;
174 174
         }
175 175
     }
176 176
 
177
-    public function deleteURL($id=null)
177
+    public function deleteURL($id = null)
178 178
     {
179
-        if($this->controller_class && method_exists($this->controller_class, 'getDelete')) {
180
-            return action($this->controller.'@getDelete',['id'=>$id]);
181
-        }else{
179
+        if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) {
180
+            return action($this->controller.'@getDelete', ['id'=>$id]);
181
+        } else {
182 182
             return null;
183 183
         }
184 184
     }
185 185
 
186 186
     public function url($path = null)
187 187
     {
188
-        if($this->controller_class && method_exists($this->controller_class, 'getIndex')) {
189
-            return trim(action($this->controller.'@getIndex').'/'.$path,'/');
190
-        }else{
188
+        if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) {
189
+            return trim(action($this->controller.'@getIndex').'/'.$path, '/');
190
+        } else {
191 191
             return null;
192 192
         }
193 193
     }
Please login to merge, or discard this patch.
src/helpers/CB.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 {
19 19
 
20 20
     public function getRoleByName($roleName) {
21
-        return $this->find("cb_roles",['name'=>$roleName]);
21
+        return $this->find("cb_roles", ['name'=>$roleName]);
22 22
     }
23 23
 
24 24
     public function fcm() {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     }
35 35
 
36 36
     public function getDeveloperUrl($path = null) {
37
-        $path = ($path)?"/".trim($path,"/"):null;
37
+        $path = ($path) ? "/".trim($path, "/") : null;
38 38
         return url(cbConfig("DEV_PATH")).$path;
39 39
     }
40 40
 
@@ -51,22 +51,22 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     public function getAdminUrl($path = null) {
54
-        $path = ($path)?"/".trim($path,"/"):null;
54
+        $path = ($path) ? "/".trim($path, "/") : null;
55 55
         return url(cbConfig("ADMIN_PATH")).$path;
56 56
     }
57 57
 
58 58
     public function getAppName() {
59
-        return env("APP_NAME","CRUDBOOSTER");
59
+        return env("APP_NAME", "CRUDBOOSTER");
60 60
     }
61 61
 
62 62
     public function uploadBase64($value)
63 63
     {
64 64
         $fileData = base64_decode($value);
65 65
         $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE);
66
-        if($mime_type) {
67
-            if($mime_type = explode('/', $mime_type)) {
66
+        if ($mime_type) {
67
+            if ($mime_type = explode('/', $mime_type)) {
68 68
                 $ext = $mime_type[1];
69
-                if($ext) {
69
+                if ($ext) {
70 70
                     $filePath = 'uploads/'.date('Y-m');
71 71
                     Storage::makeDirectory($filePath);
72 72
                     $filename = sha1(strRandom(5)).'.'.$ext;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
             $file = request()->file($name);
88 88
             $ext = $file->getClientOriginalExtension();
89
-            if(in_array($ext,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
89
+            if (in_array($ext, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
90 90
                 $filename = slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
91 91
                 $file_path = 'uploads/'.date('Y-m');
92 92
 
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
                 }
101 101
 
102 102
                 if (Storage::putFileAs($file_path, $file, $filename)) {
103
-                    if($resize_width || $resize_height) {
103
+                    if ($resize_width || $resize_height) {
104 104
                         $this->resizeImage($file_path.'/'.$filename, $resize_width, $resize_height);
105 105
                     }
106 106
                     return $file_path.'/'.$filename;
107 107
                 } else {
108 108
                     throw new \Exception("Something went wrong, file can't upload!");
109 109
                 }
110
-            }else{
110
+            } else {
111 111
                 throw new \Exception("The file format is not allowed!");
112 112
             }
113 113
 
@@ -130,22 +130,22 @@  discard block
 block discarded – undo
130 130
                 $img = Image::make(storage_path('app/'.$file_path.'/'.$filename));
131 131
                 $img->fit($resize_width, $resize_height);
132 132
                 $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty);
133
-            } elseif ($resize_width && ! $resize_height) {
133
+            } elseif ($resize_width && !$resize_height) {
134 134
                 $img = Image::make(storage_path('app/'.$file_path.'/'.$filename));
135
-                $img->resize($resize_width, null, function ($constraint) {
135
+                $img->resize($resize_width, null, function($constraint) {
136 136
                     $constraint->aspectRatio();
137 137
                 });
138 138
                 $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty);
139
-            } elseif (! $resize_width && $resize_height) {
139
+            } elseif (!$resize_width && $resize_height) {
140 140
                 $img = Image::make(storage_path('app/'.$file_path.'/'.$filename));
141
-                $img->resize(null, $resize_height, function ($constraint) {
141
+                $img->resize(null, $resize_height, function($constraint) {
142 142
                     $constraint->aspectRatio();
143 143
                 });
144 144
                 $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty);
145 145
             } else {
146 146
                 $img = Image::make(storage_path('app/'.$file_path.'/'.$filename));
147 147
                 if ($img->width() > 1300) {
148
-                    $img->resize(1300, null, function ($constraint) {
148
+                    $img->resize(1300, null, function($constraint) {
149 149
                         $constraint->aspectRatio();
150 150
                     });
151 151
                 }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $validator = Validator::make($input_arr, $rules, $messages);
258 258
         if ($validator->fails()) {
259 259
             $message = $validator->errors()->all();
260
-            throw new CBValidationException(implode("; ",$message));
260
+            throw new CBValidationException(implode("; ", $message));
261 261
         }
262 262
     }
263 263
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     public function findPrimaryKey($table)
270 270
     {
271 271
         $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
272
-        if(!$pk) {
272
+        if (!$pk) {
273 273
             return null;
274 274
         }
275 275
         return $pk->getColumns()[0];
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
             $string_parameters_array = explode('&', $string_parameters);
319 319
             foreach ($string_parameters_array as $s) {
320 320
                 $part = explode('=', $s);
321
-                if(isset($part[0]) && isset($part[1])) {
321
+                if (isset($part[0]) && isset($part[1])) {
322 322
                     $name = htmlspecialchars(urldecode($part[0]));
323 323
                     $name = strip_tags($name);
324 324
                     $value = htmlspecialchars(urldecode($part[1]));
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 
336 336
 
337 337
     public function routeGet($prefix, $controller) {
338
-        $alias = str_replace("@"," ", $controller);
338
+        $alias = str_replace("@", " ", $controller);
339 339
         $alias = ucwords($alias);
340
-        $alias = str_replace(" ","",$alias);
340
+        $alias = str_replace(" ", "", $alias);
341 341
         Route::get($prefix, ['uses' => $controller, 'as' => $alias]);
342 342
     }
343 343
 
344 344
     public function routePost($prefix, $controller) {
345
-        $alias = str_replace("@"," ", $controller);
345
+        $alias = str_replace("@", " ", $controller);
346 346
         $alias = ucwords($alias);
347
-        $alias = str_replace(" ","",$alias);
347
+        $alias = str_replace(" ", "", $alias);
348 348
         Route::post($prefix, ['uses' => $controller, 'as' => $alias]);
349 349
     }
350 350
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
         $prefix = trim($prefix, '/').'/';
372 372
 
373
-        if(substr($controller,0,1) != "\\") {
373
+        if (substr($controller, 0, 1) != "\\") {
374 374
             $controller = "\App\Http\Controllers\\".$controller;
375 375
         }
376 376
 
Please login to merge, or discard this patch.
src/commands/Generate.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@
 block discarded – undo
32 32
     {
33 33
         $this->info($this->description);
34 34
         $option = $this->option("module");
35
-        if($option == "ALL") {
35
+        if ($option == "ALL") {
36 36
             $tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
37
-            foreach($tables as $table) {
37
+            foreach ($tables as $table) {
38 38
                 $this->generate($table);
39 39
             }
40
-        }else{
40
+        } else {
41 41
             $this->generate($option);
42 42
         }
43 43
     }
Please login to merge, or discard this patch.