Passed
Push — master ( ab23d3...456c2a )
by Ferry
05:06
created
src/controllers/traits/Query.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
 
25 25
         $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key');
26 26
 
27
-        $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true;
28
-        if($softDelete === true && SchemaHelper::hasColumn($this->data['table'],'deleted_at')) {
27
+        $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true;
28
+        if ($softDelete === true && SchemaHelper::hasColumn($this->data['table'], 'deleted_at')) {
29 29
             $query->whereNull($this->data['table'].'.deleted_at');
30 30
         }
31 31
 
32
-        if(isset($joins)) {
33
-            foreach($joins as $join)
32
+        if (isset($joins)) {
33
+            foreach ($joins as $join)
34 34
             {
35 35
                 $query->join($join['target_table'],
36 36
                     $join['target_table_primary'],
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
             }
41 41
         }
42 42
 
43
-        foreach($columns as $column) {
43
+        foreach ($columns as $column) {
44 44
             /** @var ColumnModel $column */
45
-            if($column->getType() != "custom") {
46
-                if(strpos($column->getField(),".") === false) {
47
-                    if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) {
45
+            if ($column->getType() != "custom") {
46
+                if (strpos($column->getField(), ".") === false) {
47
+                    if (SchemaHelper::hasColumn($this->data['table'], $column->getField())) {
48 48
                         $query->addSelect($this->data['table'].'.'.$column->getField());
49 49
                     }
50
-                }else{
50
+                } else {
51 51
                     $query->addSelect($column->getField());
52 52
                 }
53 53
             }
@@ -55,20 +55,20 @@  discard block
 block discarded – undo
55 55
             $query = getTypeHook($column->getType())->query($query, $column);
56 56
         }
57 57
 
58
-        if(request()->has('q'))
58
+        if (request()->has('q'))
59 59
         {
60
-            if(isset($this->data['hook_search_query'])) {
60
+            if (isset($this->data['hook_search_query'])) {
61 61
                 $query = call_user_func($this->data['hook_search_query'], $query);
62
-            }else{
63
-                $query->where(function ($where) use ($columns) {
62
+            } else {
63
+                $query->where(function($where) use ($columns) {
64 64
                     /**
65 65
                      * @var $where Builder
66 66
                      */
67
-                    foreach($columns as $column)
67
+                    foreach ($columns as $column)
68 68
                     {
69
-                        if(strpos($column->getField(),".") === false) {
69
+                        if (strpos($column->getField(), ".") === false) {
70 70
                             $field = $this->data['table'].'.'.$column->getField();
71
-                        }else{
71
+                        } else {
72 72
                             $field = $column->getField();
73 73
                         }
74 74
                         $where->orWhere($field, 'like', '%'.request('q').'%');
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 
80 80
 
81 81
         // Callback From this Method
82
-        if(isset($callback) && is_callable($callback)) {
82
+        if (isset($callback) && is_callable($callback)) {
83 83
             $query = call_user_func($callback, $query);
84 84
         }
85 85
 
86
-        if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) {
86
+        if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) {
87 87
             $query = call_user_func($this->data['hook_index_query'], $query);
88 88
         }
89 89
 
90 90
 
91
-        if(request()->has(['order_by','order_sort']))
91
+        if (request()->has(['order_by', 'order_sort']))
92 92
         {
93
-            if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) {
93
+            if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) {
94 94
                 $query->orderBy(request('order_by'), request('order_sort'));
95 95
             }
96
-        }else{
96
+        } else {
97 97
             $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc");
98 98
         }
99 99
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
                     if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) {
48 48
                         $query->addSelect($this->data['table'].'.'.$column->getField());
49 49
                     }
50
-                }else{
50
+                } else{
51 51
                     $query->addSelect($column->getField());
52 52
                 }
53 53
             }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         {
60 60
             if(isset($this->data['hook_search_query'])) {
61 61
                 $query = call_user_func($this->data['hook_search_query'], $query);
62
-            }else{
62
+            } else{
63 63
                 $query->where(function ($where) use ($columns) {
64 64
                     /**
65 65
                      * @var $where Builder
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                     {
69 69
                         if(strpos($column->getField(),".") === false) {
70 70
                             $field = $this->data['table'].'.'.$column->getField();
71
-                        }else{
71
+                        } else{
72 72
                             $field = $column->getField();
73 73
                         }
74 74
                         $where->orWhere($field, 'like', '%'.request('q').'%');
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) {
94 94
                 $query->orderBy(request('order_by'), request('order_sort'));
95 95
             }
96
-        }else{
96
+        } else{
97 97
             $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc");
98 98
         }
99 99
 
Please login to merge, or discard this patch.
src/controllers/traits/Validation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@
 block discarded – undo
19 19
      */
20 20
     private function validation()
21 21
     {
22
-        if(isset($this->data['validation'])) {
22
+        if (isset($this->data['validation'])) {
23 23
             $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']);
24 24
             if ($validator->fails()) {
25 25
                 $message = $validator->messages();
26 26
                 $message_all = $message->all();
27
-                throw new CBValidationException(implode(', ',$message_all));
27
+                throw new CBValidationException(implode(', ', $message_all));
28 28
             }
29 29
         }
30 30
     }
Please login to merge, or discard this patch.
src/helpers/SidebarMenus.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     private function assignToModel($menu) {
24 24
         $model = new SidebarModel();
25 25
         $model->setId($menu->id);
26
-        if($menu->type == "url") {
26
+        if ($menu->type == "url") {
27 27
             $model->setUrl($menu->path);
28 28
             $model->setIcon($menu->icon);
29 29
             $model->setName($menu->name);
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
             $model->setBasepath(config('crudbooster.ADMIN_PATH').'/'.basename($model->getUrl()));
45 45
         }
46 46
 
47
-        if(request()->is($model->getBasepath()."*")) {
47
+        if (request()->is($model->getBasepath()."*")) {
48 48
             $model->setIsActive(true);
49
-        }else{
49
+        } else {
50 50
             $model->setIsActive(false);
51 51
         }
52 52
 
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 
56 56
     private function loadData($parent_id = null) {
57 57
         $menus = DB::table("cb_menus");
58
-        if($parent_id) {
59
-            $menus->where("parent_cb_menus_id",$parent_id);
60
-        }else{
58
+        if ($parent_id) {
59
+            $menus->where("parent_cb_menus_id", $parent_id);
60
+        } else {
61 61
             $menus->whereNull("parent_cb_menus_id");
62 62
         }
63
-        return $menus->orderBy("sort_number","asc")->get();
63
+        return $menus->orderBy("sort_number", "asc")->get();
64 64
     }
65 65
 
66 66
     private function rolePrivilege($cb_roles_id, $cb_menus_id) {
67
-        return cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id]);
67
+        return cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id]);
68 68
     }
69 69
 
70
-    private function checkPrivilege($roles_id,$menu) {
71
-        if($roles_id) {
70
+    private function checkPrivilege($roles_id, $menu) {
71
+        if ($roles_id) {
72 72
             $privilege = $this->rolePrivilege($roles_id, $menu->id);
73
-            if($privilege && !$privilege->can_browse) {
73
+            if ($privilege && !$privilege->can_browse) {
74 74
                 return false;
75 75
             }
76 76
         }
@@ -79,39 +79,39 @@  discard block
 block discarded – undo
79 79
     }
80 80
 
81 81
     public function all($withPrivilege = true) {
82
-        $roles_id = ($withPrivilege)?cb()->session()->roleId():null;
82
+        $roles_id = ($withPrivilege) ?cb()->session()->roleId() : null;
83 83
         $idHash = "menuUser".$roles_id.auth()->id();
84
-        if($menu = CacheHelper::getItemInGroup($idHash,"sidebar_menu")) return $menu;
84
+        if ($menu = CacheHelper::getItemInGroup($idHash, "sidebar_menu")) return $menu;
85 85
 
86 86
         $menus = $this->loadData();
87 87
         $result = [];
88 88
         $menus_active = false;
89
-        foreach($menus as $menu) {
89
+        foreach ($menus as $menu) {
90 90
 
91
-            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
91
+            if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
92 92
 
93 93
             $sidebarModel = $this->assignToModel($menu);
94
-            if($sidebarModel->getisActive()) $menus_active = true;
95
-            if($menus2 = $this->loadData($menu->id)) {
94
+            if ($sidebarModel->getisActive()) $menus_active = true;
95
+            if ($menus2 = $this->loadData($menu->id)) {
96 96
                 $sub1 = [];
97 97
                 $menus2_active = false;
98 98
                 foreach ($menus2 as $menu2) {
99 99
 
100
-                    if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
100
+                    if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
101 101
 
102 102
                     $sidebarModel2 = $this->assignToModel($menu2);
103
-                    if($sidebarModel2->getisActive()) $menus2_active = true;
103
+                    if ($sidebarModel2->getisActive()) $menus2_active = true;
104 104
 
105
-                    if($menus3 = $this->loadData($menu2->id)) {
105
+                    if ($menus3 = $this->loadData($menu2->id)) {
106 106
                         $sub2 = [];
107 107
                         $menus3_active = false;
108 108
                         foreach ($menus3 as $menu3) {
109 109
 
110
-                            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
110
+                            if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
111 111
 
112 112
                             $sidebarModel3 = $this->assignToModel($menu3);
113 113
 
114
-                            if($sidebarModel3->getisActive()) {
114
+                            if ($sidebarModel3->getisActive()) {
115 115
                                 $menus3_active = true;
116 116
                             }
117 117
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             $result[] = $sidebarModel;
129 129
         }
130 130
 
131
-        CacheHelper::putInGroup($idHash, $result,"sidebar_menu", 3600);
131
+        CacheHelper::putInGroup($idHash, $result, "sidebar_menu", 3600);
132 132
         return $result;
133 133
     }
134 134
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
             $model->setIcon($menu->icon);
29 29
             $model->setName($menu->name);
30 30
             $model->setBasepath(basename($model->getUrl()));
31
-        }elseif ($menu->type == "module") {
31
+        } elseif ($menu->type == "module") {
32 32
             $module = cb()->find("cb_modules", $menu->cb_modules_id);
33 33
             $className = '\App\Http\Controllers\\'.$module->controller;
34 34
             $controllerClass = new $className();
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             $model->setIcon($module->icon);
38 38
             $model->setName($module->name);
39 39
             $model->setBasepath(config('crudbooster.ADMIN_PATH').'/'.basename($model->getUrl()));
40
-        }elseif ($menu->type == "path") {
40
+        } elseif ($menu->type == "path") {
41 41
             $model->setUrl(cb()->getAdminUrl($menu->path));
42 42
             $model->setIcon($menu->icon);
43 43
             $model->setName($menu->name);
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
         if(request()->is($model->getBasepath()."*")) {
48 48
             $model->setIsActive(true);
49
-        }else{
49
+        } else{
50 50
             $model->setIsActive(false);
51 51
         }
52 52
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $menus = DB::table("cb_menus");
58 58
         if($parent_id) {
59 59
             $menus->where("parent_cb_menus_id",$parent_id);
60
-        }else{
60
+        } else{
61 61
             $menus->whereNull("parent_cb_menus_id");
62 62
         }
63 63
         return $menus->orderBy("sort_number","asc")->get();
@@ -81,33 +81,45 @@  discard block
 block discarded – undo
81 81
     public function all($withPrivilege = true) {
82 82
         $roles_id = ($withPrivilege)?cb()->session()->roleId():null;
83 83
         $idHash = "menuUser".$roles_id.auth()->id();
84
-        if($menu = CacheHelper::getItemInGroup($idHash,"sidebar_menu")) return $menu;
84
+        if($menu = CacheHelper::getItemInGroup($idHash,"sidebar_menu")) {
85
+            return $menu;
86
+        }
85 87
 
86 88
         $menus = $this->loadData();
87 89
         $result = [];
88 90
         $menus_active = false;
89 91
         foreach($menus as $menu) {
90 92
 
91
-            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
93
+            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) {
94
+                continue;
95
+            }
92 96
 
93 97
             $sidebarModel = $this->assignToModel($menu);
94
-            if($sidebarModel->getisActive()) $menus_active = true;
98
+            if($sidebarModel->getisActive()) {
99
+                $menus_active = true;
100
+            }
95 101
             if($menus2 = $this->loadData($menu->id)) {
96 102
                 $sub1 = [];
97 103
                 $menus2_active = false;
98 104
                 foreach ($menus2 as $menu2) {
99 105
 
100
-                    if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
106
+                    if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) {
107
+                        continue;
108
+                    }
101 109
 
102 110
                     $sidebarModel2 = $this->assignToModel($menu2);
103
-                    if($sidebarModel2->getisActive()) $menus2_active = true;
111
+                    if($sidebarModel2->getisActive()) {
112
+                        $menus2_active = true;
113
+                    }
104 114
 
105 115
                     if($menus3 = $this->loadData($menu2->id)) {
106 116
                         $sub2 = [];
107 117
                         $menus3_active = false;
108 118
                         foreach ($menus3 as $menu3) {
109 119
 
110
-                            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
120
+                            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) {
121
+                                continue;
122
+                            }
111 123
 
112 124
                             $sidebarModel3 = $this->assignToModel($menu3);
113 125
 
Please login to merge, or discard this patch.
src/helpers/MiscellanousSingleton.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 
24 24
     public function hasData($key) {
25 25
         $data = $this->data;
26
-        if(isset($data[$key])) return true;
26
+        if (isset($data[$key])) return true;
27 27
         else return false;
28 28
     }
29 29
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,11 @@
 block discarded – undo
23 23
 
24 24
     public function hasData($key) {
25 25
         $data = $this->data;
26
-        if(isset($data[$key])) return true;
27
-        else return false;
26
+        if(isset($data[$key])) {
27
+            return true;
28
+        } else {
29
+            return false;
30
+        }
28 31
     }
29 32
 
30 33
     public function setData($key, $value): void
Please login to merge, or discard this patch.
src/helpers/SchemaHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,6 +16,6 @@
 block discarded – undo
16 16
     public static function hasColumn($table, $column)
17 17
     {
18 18
         $columns = cb()->listAllColumns($table);
19
-        return in_array($column,$columns);
19
+        return in_array($column, $columns);
20 20
     }
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/helpers/CB.php 2 patches
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
     public function getRoleByName($roleName) {
27
-        return $this->find("cb_roles",['name'=>$roleName]);
27
+        return $this->find("cb_roles", ['name'=>$roleName]);
28 28
     }
29 29
 
30 30
     public function fcm() {
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     }
41 41
 
42 42
     public function getDeveloperUrl($path = null) {
43
-        $path = ($path)?"/".trim($path,"/"):null;
43
+        $path = ($path) ? "/".trim($path, "/") : null;
44 44
         return url("developer/".getSetting("developer_path")).$path;
45 45
     }
46 46
 
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
     }
58 58
 
59 59
     public function getAdminPath() {
60
-        return getSetting("ADMIN_PATH","admin");
60
+        return getSetting("ADMIN_PATH", "admin");
61 61
     }
62 62
 
63 63
     public function getAdminUrl($path = null) {
64
-        $path = ($path)?"/".trim($path,"/"):null;
64
+        $path = ($path) ? "/".trim($path, "/") : null;
65 65
         return url($this->getAdminPath()).$path;
66 66
     }
67 67
 
68 68
     public function getAppName() {
69
-        return getSetting("APP_NAME", env("APP_NAME","CRUDBOOSTER"));
69
+        return getSetting("APP_NAME", env("APP_NAME", "CRUDBOOSTER"));
70 70
     }
71 71
 
72 72
     /**
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
      */
81 81
     private function uploadFileProcess($filename, $extension, $file, $encrypt = true, $resize_width = null, $resize_height = null)
82 82
     {
83
-        if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
83
+        if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
84 84
             $file_path = cbConfig("UPLOAD_PATH_FORMAT");
85
-            $file_path = str_replace("{Y}",date('Y'), $file_path);
85
+            $file_path = str_replace("{Y}", date('Y'), $file_path);
86 86
             $file_path = str_replace("{m}", date('m'), $file_path);
87 87
             $file_path = str_replace("{d}", date("d"), $file_path);
88 88
 
89 89
             //Create Directory Base On Template
90 90
             Storage::makeDirectory($file_path);
91
-            Storage::put($file_path."/index.html"," ","public");
92
-            Storage::put($file_path."/.gitignore","!.gitignore","public");
91
+            Storage::put($file_path."/index.html", " ", "public");
92
+            Storage::put($file_path."/.gitignore", "!.gitignore", "public");
93 93
 
94 94
             if ($encrypt == true) {
95 95
                 $filename = md5(strRandom(5)).'.'.$extension;
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
                 $filename = slug($filename, '_').'.'.$extension;
98 98
             }
99 99
 
100
-            if($resize_width || $resize_height) {
100
+            if ($resize_width || $resize_height) {
101 101
                 $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height);
102 102
                 return $file_path.'/'.$filename;
103
-            }else{
103
+            } else {
104 104
                 if (Storage::putFileAs($file_path, $file, $filename, 'public')) {
105 105
                     return $file_path.'/'.$filename;
106 106
                 } else {
107 107
                     throw new \Exception("Something went wrong, file can't upload!");
108 108
                 }
109 109
             }
110
-        }else{
110
+        } else {
111 111
             throw new \Exception("The file format is not allowed!");
112 112
         }
113 113
     }
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $fileData = base64_decode($base64_value);
125 125
         $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE);
126
-        if($mime_type) {
127
-            if($mime_type = explode('/', $mime_type)) {
126
+        if ($mime_type) {
127
+            if ($mime_type = explode('/', $mime_type)) {
128 128
                 $ext = $mime_type[1];
129
-                if($filename && $ext) {
129
+                if ($filename && $ext) {
130 130
                     return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height);
131 131
                 }
132
-            }else {
132
+            } else {
133 133
                 throw new \Exception("Mime type not found");
134 134
             }
135
-        }else{
135
+        } else {
136 136
             throw new \Exception("Mime type not found");
137 137
         }
138 138
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             $filename = $file->getClientOriginalName();
153 153
             $ext = strtolower($file->getClientOriginalExtension());
154 154
 
155
-            if($filename && $ext) {
155
+            if ($filename && $ext) {
156 156
                 return $this->uploadFileProcess($filename, $ext, $file, $encrypt, $resize_width, $resize_height);
157 157
             }
158 158
 
@@ -187,29 +187,29 @@  discard block
 block discarded – undo
187 187
             if ($resize_width && $resize_height) {
188 188
                 $img->fit($resize_width, $resize_height);
189 189
 
190
-            } elseif ($resize_width && ! $resize_height) {
190
+            } elseif ($resize_width && !$resize_height) {
191 191
 
192
-                $img->resize($resize_width, null, function ($constraint) {
192
+                $img->resize($resize_width, null, function($constraint) {
193 193
                     $constraint->aspectRatio();
194 194
                 });
195 195
 
196
-            } elseif (! $resize_width && $resize_height) {
196
+            } elseif (!$resize_width && $resize_height) {
197 197
 
198
-                $img->resize(null, $resize_height, function ($constraint) {
198
+                $img->resize(null, $resize_height, function($constraint) {
199 199
                     $constraint->aspectRatio();
200 200
                 });
201 201
 
202 202
             } else {
203 203
 
204 204
                 if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) {
205
-                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) {
205
+                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) {
206 206
                         $constraint->aspectRatio();
207 207
                     });
208 208
                 }
209 209
             }
210 210
 
211 211
             Storage::put($fullFilePath, $img, 'public');
212
-        }else{
212
+        } else {
213 213
             throw new \Exception("The file format is not allowed!");
214 214
         }
215 215
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     {
234 234
         if (is_array($id)) {
235 235
             $idHash = md5("find".$table.serialize($id));
236
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
236
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
237 237
 
238 238
             $first = DB::table($table);
239 239
             foreach ($id as $k => $v) {
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
             }
242 242
 
243 243
             $data = $first->first();
244
-            miscellanousSingleton()->setData($idHash,$data);
244
+            miscellanousSingleton()->setData($idHash, $data);
245 245
             return $data;
246 246
         } else {
247 247
             $idHash = md5("find".$table.$id);
248
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
248
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
249 249
 
250 250
             $pk = $this->pk($table);
251 251
             $data = DB::table($table)->where($pk, $id)->first();
252
-            miscellanousSingleton()->setData($idHash,$data);
252
+            miscellanousSingleton()->setData($idHash, $data);
253 253
             return $data;
254 254
         }
255 255
     }
@@ -264,30 +264,30 @@  discard block
 block discarded – undo
264 264
         $data = [];
265 265
         $idHash = null;
266 266
 
267
-        if(is_array($conditionOrCallback)) {
267
+        if (is_array($conditionOrCallback)) {
268 268
             $idHash = md5("findAll".$table.serialize($conditionOrCallback));
269
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
269
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
270 270
 
271 271
             $data = DB::table($table)->where($conditionOrCallback)->get();
272 272
         } elseif (is_callable($conditionOrCallback)) {
273 273
             $idHash = "findAll".$table.spl_object_hash($conditionOrCallback);
274
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
274
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
275 275
 
276 276
             $data = DB::table($table);
277 277
             $data = call_user_func($conditionOrCallback, $data);
278 278
             $data = $data->get();
279 279
         } else {
280 280
             $idHash = md5("findAll".$table.$conditionOrCallback);
281
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
281
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
282 282
 
283 283
             $data = DB::table($table);
284
-            if($conditionOrCallback) {
284
+            if ($conditionOrCallback) {
285 285
                 $data = $data->whereRaw($conditionOrCallback);
286 286
             }
287 287
             $data = $data->get();
288 288
         }
289 289
 
290
-        if($idHash && $data) {
290
+        if ($idHash && $data) {
291 291
             miscellanousSingleton()->setData($idHash, $data);
292 292
         }
293 293
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     public function listAllTable()
298 298
     {
299 299
         $idHash = md5("listAllTable");
300
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
300
+        if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
301 301
         $data = DB::connection()->getDoctrineSchemaManager()->listTableNames();
302 302
         miscellanousSingleton()->setData($idHash, $data);
303 303
         return $data;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     public function listAllColumns($table)
307 307
     {
308 308
         $idHash = md5("listAllColumns".$table);
309
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
309
+        if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
310 310
         $data = Schema::getColumnListing($table);
311 311
         miscellanousSingleton()->setData($idHash, $data);
312 312
         return $data;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
         $validator = Validator::make($input_arr, $rules, $messages);
375 375
         if ($validator->fails()) {
376 376
             $message = $validator->errors()->all();
377
-            throw new CBValidationException(implode("; ",$message));
377
+            throw new CBValidationException(implode("; ", $message));
378 378
         }
379 379
     }
380 380
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     public function findPrimaryKey($table)
387 387
     {
388 388
         $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
389
-        if(!$pk) {
389
+        if (!$pk) {
390 390
             return null;
391 391
         }
392 392
         return $pk->getColumns()[0];
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
             $string_parameters_array = explode('&', $string_parameters);
436 436
             foreach ($string_parameters_array as $s) {
437 437
                 $part = explode('=', $s);
438
-                if(isset($part[0]) && isset($part[1])) {
438
+                if (isset($part[0]) && isset($part[1])) {
439 439
                     $name = htmlspecialchars(urldecode($part[0]));
440 440
                     $name = strip_tags($name);
441 441
                     $value = htmlspecialchars(urldecode($part[1]));
@@ -452,16 +452,16 @@  discard block
 block discarded – undo
452 452
 
453 453
 
454 454
     public function routeGet($prefix, $controller) {
455
-        $alias = str_replace("@"," ", $controller);
455
+        $alias = str_replace("@", " ", $controller);
456 456
         $alias = ucwords($alias);
457
-        $alias = str_replace(" ","",$alias);
457
+        $alias = str_replace(" ", "", $alias);
458 458
         Route::get($prefix, ['uses' => $controller, 'as' => $alias]);
459 459
     }
460 460
 
461 461
     public function routePost($prefix, $controller) {
462
-        $alias = str_replace("@"," ", $controller);
462
+        $alias = str_replace("@", " ", $controller);
463 463
         $alias = ucwords($alias);
464
-        $alias = str_replace(" ","",$alias);
464
+        $alias = str_replace(" ", "", $alias);
465 465
         Route::post($prefix, ['uses' => $controller, 'as' => $alias]);
466 466
     }
467 467
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 
495 495
         $prefix = trim($prefix, '/').'/';
496 496
 
497
-        if(substr($controller,0,1) != "\\") {
497
+        if (substr($controller, 0, 1) != "\\") {
498 498
             $controller = "\App\Http\Controllers\\".$controller;
499 499
         }
500 500
 
Please login to merge, or discard this patch.
Braces   +26 added lines, -12 removed lines patch added patch discarded remove patch
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
             if($resize_width || $resize_height) {
101 101
                 $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height);
102 102
                 return $file_path.'/'.$filename;
103
-            }else{
103
+            } else{
104 104
                 if (Storage::putFileAs($file_path, $file, $filename, 'public')) {
105 105
                     return $file_path.'/'.$filename;
106 106
                 } else {
107 107
                     throw new \Exception("Something went wrong, file can't upload!");
108 108
                 }
109 109
             }
110
-        }else{
110
+        } else{
111 111
             throw new \Exception("The file format is not allowed!");
112 112
         }
113 113
     }
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
                 if($filename && $ext) {
130 130
                     return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height);
131 131
                 }
132
-            }else {
132
+            } else {
133 133
                 throw new \Exception("Mime type not found");
134 134
             }
135
-        }else{
135
+        } else{
136 136
             throw new \Exception("Mime type not found");
137 137
         }
138 138
     }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             }
210 210
 
211 211
             Storage::put($fullFilePath, $img, 'public');
212
-        }else{
212
+        } else{
213 213
             throw new \Exception("The file format is not allowed!");
214 214
         }
215 215
     }
@@ -233,7 +233,9 @@  discard block
 block discarded – undo
233 233
     {
234 234
         if (is_array($id)) {
235 235
             $idHash = md5("find".$table.serialize($id));
236
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
236
+            if(miscellanousSingleton()->hasData($idHash)) {
237
+                return miscellanousSingleton()->getData($idHash);
238
+            }
237 239
 
238 240
             $first = DB::table($table);
239 241
             foreach ($id as $k => $v) {
@@ -245,7 +247,9 @@  discard block
 block discarded – undo
245 247
             return $data;
246 248
         } else {
247 249
             $idHash = md5("find".$table.$id);
248
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
250
+            if(miscellanousSingleton()->hasData($idHash)) {
251
+                return miscellanousSingleton()->getData($idHash);
252
+            }
249 253
 
250 254
             $pk = $this->pk($table);
251 255
             $data = DB::table($table)->where($pk, $id)->first();
@@ -266,19 +270,25 @@  discard block
 block discarded – undo
266 270
 
267 271
         if(is_array($conditionOrCallback)) {
268 272
             $idHash = md5("findAll".$table.serialize($conditionOrCallback));
269
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
273
+            if(miscellanousSingleton()->hasData($idHash)) {
274
+                return miscellanousSingleton()->getData($idHash);
275
+            }
270 276
 
271 277
             $data = DB::table($table)->where($conditionOrCallback)->get();
272 278
         } elseif (is_callable($conditionOrCallback)) {
273 279
             $idHash = "findAll".$table.spl_object_hash($conditionOrCallback);
274
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
280
+            if(miscellanousSingleton()->hasData($idHash)) {
281
+                return miscellanousSingleton()->getData($idHash);
282
+            }
275 283
 
276 284
             $data = DB::table($table);
277 285
             $data = call_user_func($conditionOrCallback, $data);
278 286
             $data = $data->get();
279 287
         } else {
280 288
             $idHash = md5("findAll".$table.$conditionOrCallback);
281
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
289
+            if(miscellanousSingleton()->hasData($idHash)) {
290
+                return miscellanousSingleton()->getData($idHash);
291
+            }
282 292
 
283 293
             $data = DB::table($table);
284 294
             if($conditionOrCallback) {
@@ -297,7 +307,9 @@  discard block
 block discarded – undo
297 307
     public function listAllTable()
298 308
     {
299 309
         $idHash = md5("listAllTable");
300
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
310
+        if(miscellanousSingleton()->hasData($idHash)) {
311
+            return miscellanousSingleton()->getData($idHash);
312
+        }
301 313
         $data = DB::connection()->getDoctrineSchemaManager()->listTableNames();
302 314
         miscellanousSingleton()->setData($idHash, $data);
303 315
         return $data;
@@ -306,7 +318,9 @@  discard block
 block discarded – undo
306 318
     public function listAllColumns($table)
307 319
     {
308 320
         $idHash = md5("listAllColumns".$table);
309
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
321
+        if(miscellanousSingleton()->hasData($idHash)) {
322
+            return miscellanousSingleton()->getData($idHash);
323
+        }
310 324
         $data = Schema::getColumnListing($table);
311 325
         miscellanousSingleton()->setData($idHash, $data);
312 326
         return $data;
Please login to merge, or discard this patch.
src/helpers/CacheHelper.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 {
16 16
     public static function putInGroup($key, $value, $group, $duration) {
17 17
         $key = md5($key);
18
-        $exist = (Cache::get($group))?:[];
19
-        $exist[ $key ] = ['value'=>$value,'duration'=>$duration];
18
+        $exist = (Cache::get($group)) ?: [];
19
+        $exist[$key] = ['value'=>$value, 'duration'=>$duration];
20 20
 
21
-        if($duration == -1) {
21
+        if ($duration == -1) {
22 22
             Cache::forever($group, $exist);
23 23
         } else {
24 24
             Cache::put($group, $exist, $duration);
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public static function getItemInGroup($key, $group) {
29 29
         $groupdata = Cache::get($group);
30 30
         $key = md5($key);
31
-        if(isset($groupdata[$key])) {
31
+        if (isset($groupdata[$key])) {
32 32
             return $groupdata[$key]['value'];
33 33
         }
34 34
         return null;
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
         Cache::forget($group);
39 39
     }
40 40
 
41
-    public static function forgetInGroup($key,$group) {
41
+    public static function forgetInGroup($key, $group) {
42 42
         $key = md5($key);
43 43
         $data = Cache::get($group);
44 44
         $duration = null;
45
-        if(isset($data[$key])) {
45
+        if (isset($data[$key])) {
46 46
             $item = $data[$key];
47 47
             unset($data[$key]);
48 48
         }
Please login to merge, or discard this patch.