Passed
Push — master ( 5b33aa...3ced8d )
by Ferry
08:41
created
src/configs/crudbooster.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@
 block discarded – undo
26 26
     /*
27 27
      * For security reason we have limit the upload file formats bellow
28 28
      */
29
-    'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif','pdf','xls','xlsx','doc','docx','txt','zip','rar','rtf'],
29
+    'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'xls', 'xlsx', 'doc', 'docx', 'txt', 'zip', 'rar', 'rtf'],
30 30
 
31
-    'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif'],
31
+    'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif'],
32 32
 
33 33
     /*
34 34
      * Data Migration table additional
35 35
      * You can define in this array what the tables you want to include in "php artisan crudbooster:data_migration"
36 36
      * The default is all cb_ prefix will be include in data migration
37 37
      */
38
-    'ADDITIONAL_DATA_MIGRATION'=>['users','migrations'],
38
+    'ADDITIONAL_DATA_MIGRATION'=>['users', 'migrations'],
39 39
 
40 40
     /*
41 41
      * Google FCM Server Key is used to send a notification via FireBase cloud message
Please login to merge, or discard this patch.
src/commands/MigrateData.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
     public function handle()
33 33
     {
34 34
 
35
-        if($this->option("generate")) {
35
+        if ($this->option("generate")) {
36 36
             $this->info("== Generating Seeder ==");
37 37
             $this->generateSeeder();
38 38
             $this->info("== Finish ==");
39
-        }else{
39
+        } else {
40 40
             $this->info("== Importing the seeder ==");
41
-            $this->call("db:seed",["--class"=>"CbMigrationSeeder"]);
41
+            $this->call("db:seed", ["--class"=>"CbMigrationSeeder"]);
42 42
             $this->info("== Finish ==");
43 43
         }
44 44
 
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
         $php_string = "";
51 51
         $additional_tables = cbConfig("ADDITIONAL_DATA_MIGRATION");
52 52
 
53
-        foreach($tables as $table) {
54
-            if(substr($table,0,3) == "cb_" || in_array($table, $additional_tables)) {
53
+        foreach ($tables as $table) {
54
+            if (substr($table, 0, 3) == "cb_" || in_array($table, $additional_tables)) {
55 55
                 $this->info("Create seeder for table : ".$table);
56 56
                 $rows = DB::table($table)->get();
57 57
                 $data = [];
58
-                foreach($rows as $i=>$row) {
58
+                foreach ($rows as $i=>$row) {
59 59
                     $data[$i] = [];
60
-                    foreach($row as $key=>$val) {
60
+                    foreach ($row as $key=>$val) {
61 61
                         $data[$i][$key] = $val;
62 62
                     }
63 63
                 }
64
-                if(count($data)!=0) {
64
+                if (count($data) != 0) {
65 65
                     $php_string .= 'DB::table(\''.$table.'\')->delete();'."\n\t\t\t";
66 66
                     $php_string .= 'DB::table(\''.$table.'\')->insert('.min_var_export($data).');'."\n\t\t\t";
67 67
                 }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         $composer_path = '';
92 92
         if (file_exists(getcwd().'/composer.phar')) {
93 93
             $composer_path = '"'.PHP_BINARY.'" '.getcwd().'/composer.phar';
94
-        }else{
94
+        } else {
95 95
             $composer_path = 'composer';
96 96
         }
97 97
 
Please login to merge, or discard this patch.
src/controllers/traits/ControllerSetting.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
         $this->setButtonDetail(true);
30 30
         $this->setButtonSave(true);
31 31
         $this->setButtonLimitPage(true);
32
-        $this->hideButtonDeleteWhen(function ($row) { return false; });
33
-        $this->hideButtonDetailWhen(function ($row) { return false; });
34
-        $this->hideButtonEditWhen(function ($row) { return false; });
35
-        $this->style(function () { return null; });
36
-        $this->javascript(function () { return null; });
32
+        $this->hideButtonDeleteWhen(function($row) { return false; });
33
+        $this->hideButtonDetailWhen(function($row) { return false; });
34
+        $this->hideButtonEditWhen(function($row) { return false; });
35
+        $this->style(function() { return null; });
36
+        $this->javascript(function() { return null; });
37 37
     }
38 38
 
39 39
     public function style(callable $style) {
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
      * @param ButtonColor $color
138 138
      * @param string $attributes
139 139
      */
140
-    public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null)
140
+    public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null)
141 141
     {
142
-        $color = ($color)?:ButtonColor::DARK_BLUE;
142
+        $color = ($color) ?: ButtonColor::DARK_BLUE;
143 143
 
144 144
         $model = new IndexActionButtonModel();
145 145
         $model->setLabel($label);
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
      * @param $fontAwesome_icon
195 195
      * @param ButtonColor|string $color
196 196
      */
197
-    public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false)
197
+    public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false)
198 198
     {
199 199
         $new = new AddActionButtonModel();
200 200
         $new->setLabel($label);
201
-        $new->setIcon($fontAwesome_icon?:"fa fa-bars");
202
-        $new->setColor($color?:"primary");
201
+        $new->setIcon($fontAwesome_icon ?: "fa fa-bars");
202
+        $new->setColor($color ?: "primary");
203 203
         $new->setUrl($url_target);
204 204
         $new->setCondition($condition_callback);
205 205
         $new->setConfirmation($confirmation);
Please login to merge, or discard this patch.
src/commands/DeveloperUser.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@
 block discarded – undo
30 30
      */
31 31
     public function handle()
32 32
     {
33
-        if($this->option("password") == "AUTO") {
33
+        if ($this->option("password") == "AUTO") {
34 34
             $password = Str::random(16);
35
-        }else{
35
+        } else {
36 36
             $password = $this->option("password");
37 37
         }
38 38
 
Please login to merge, or discard this patch.
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/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.
src/routes.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Developer Backend Middleware
4
-Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
4
+Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
5 5
     'prefix'=>cbConfig('DEV_PATH'),
6
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
6
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
7 7
     cb()->routeController("modules", "\crocodicstudio\crudbooster\controllers\DeveloperModulesController");
8 8
     cb()->routeController("menus", "\crocodicstudio\crudbooster\controllers\DeveloperMenusController");
9
-    cb()->routeController("roles","\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
-    cb()->routeController("users","\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
-    cb()->routeGet("/","DeveloperDashboardController@getIndex");
9
+    cb()->routeController("roles", "\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
+    cb()->routeController("users", "\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
+    cb()->routeGet("/", "DeveloperDashboardController@getIndex");
12 12
 });
13 13
 
14 14
 // Developer Auth Middleware
15 15
 Route::group(['middleware' => ['web'],
16 16
     'prefix'=>cbConfig('DEV_PATH'),
17
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
18
-    cb()->routePost("login","AdminAuthController@postLoginDeveloper");
19
-    cb()->routeGet("login","AdminAuthController@getLoginDeveloper");
20
-    cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper");
17
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
18
+    cb()->routePost("login", "AdminAuthController@postLoginDeveloper");
19
+    cb()->routeGet("login", "AdminAuthController@getLoginDeveloper");
20
+    cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper");
21 21
 });
22 22
 
23 23
 // Routing without any middleware
24
-Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () {
24
+Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() {
25 25
     cb()->routeGet('uploads/{one?}/{two?}/{three?}/{four?}/{five?}', "FileController@getPreview");
26 26
 });
27 27
 
28 28
 // Routing without any middleware with admin prefix
29
-Route::group(['middleware' => ['web'], 'prefix' => cbConfig('ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
29
+Route::group(['middleware' => ['web'], 'prefix' => cbConfig('ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
30 30
     cb()->routeGet('logout', "AdminAuthController@getLogout");
31 31
     cb()->routePost('login', "AdminAuthController@postLogin");
32 32
     cb()->routeGet('login', "AdminAuthController@getLogin");
33 33
 });
34 34
 
35 35
 // Routing package controllers
36
-cb()->routeGroupBackend(function () {
36
+cb()->routeGroupBackend(function() {
37 37
     cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController');
38 38
 });
39 39
 
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
     'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class],
43 43
     'prefix' => cbConfig('ADMIN_PATH'),
44 44
     'namespace' => 'App\Http\Controllers',
45
-], function () {
45
+], function() {
46 46
 
47 47
     if (Request::is(cbConfig('ADMIN_PATH'))) {
48
-        if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
48
+        if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
49 49
             cb()->routeGet("/", $dashboard);
50
-        }else{
50
+        } else {
51 51
             cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex");
52 52
         }
53 53
     }
54 54
 
55 55
     $controllers = glob(app_path('Http/Controllers/Admin*Controller.php'));
56 56
 
57
-    foreach($controllers as $controller) {
57
+    foreach ($controllers as $controller) {
58 58
         $controllerName = basename($controller);
59
-        $controllerName = rtrim($controllerName,".php");
59
+        $controllerName = rtrim($controllerName, ".php");
60 60
         $className = '\App\Http\Controllers\\'.$controllerName;
61 61
         $controllerClass = new $className();
62
-        if(method_exists($controllerClass, 'cbInit')) {
62
+        if (method_exists($controllerClass, 'cbInit')) {
63 63
             cb()->routeController($controllerClass->getData('permalink'), $controllerName);
64 64
         }
65 65
     }
Please login to merge, or discard this patch.
src/types/radio/Radio.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) {
37 37
 
38
-        if(strpos($table,"App\Models")!==false) {
38
+        if (strpos($table, "App\Models") !== false) {
39 39
             $table = new $table();
40 40
             $table = $table::$tableName;
41 41
         }
42 42
 
43 43
         $data = DB::table($table);
44
-        if($SQLCondition && is_callable($SQLCondition)) {
44
+        if ($SQLCondition && is_callable($SQLCondition)) {
45 45
             $data = call_user_func($SQLCondition, $data);
46 46
         }elseif ($SQLCondition && is_string($SQLCondition)) {
47 47
             $data->whereRaw($SQLCondition);
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $data = $data->get();
50 50
         $options = [];
51 51
         foreach ($data as $d) {
52
-            $options[ $d->$key_field ] = $d->$display_field;
52
+            $options[$d->$key_field] = $d->$display_field;
53 53
         }
54 54
         $this->options($options);
55 55
     }
Please login to merge, or discard this patch.
src/types/checkbox/Checkbox.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      * @param $SQLCondition string|callable
41 41
      */
42 42
     public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) {
43
-        if(strpos($table,"App\Models")!==false) {
43
+        if (strpos($table, "App\Models") !== false) {
44 44
             $table = new $table();
45 45
             $table = $table::$tableName;
46 46
         }
47 47
 
48 48
         $data = DB::table($table);
49
-        if($SQLCondition && is_callable($SQLCondition)) {
49
+        if ($SQLCondition && is_callable($SQLCondition)) {
50 50
             $data = call_user_func($SQLCondition, $data);
51 51
         }elseif ($SQLCondition && is_string($SQLCondition)) {
52 52
             $data->whereRaw($SQLCondition);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $data = $data->get();
55 55
         $options = [];
56 56
         foreach ($data as $d) {
57
-            $options[ $d->$key_field ] = $d->$display_field;
57
+            $options[$d->$key_field] = $d->$display_field;
58 58
         }
59 59
         $this->options($options);
60 60
     }
Please login to merge, or discard this patch.