Passed
Push — master ( 6b3304...34df25 )
by Ferry
03:52
created
src/helpers/Plugin.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,26 +15,26 @@  discard block
 block discarded – undo
15 15
 
16 16
     public static function has($key)
17 17
     {
18
-        if(file_exists(app_path("CBPlugins/".$key))) return true;
18
+        if (file_exists(app_path("CBPlugins/".$key))) return true;
19 19
         else return false;
20 20
     }
21 21
 
22 22
     public static function isNeedUpgrade($pluginKey, $versionToCompare)
23 23
     {
24 24
         $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$pluginKey."/plugin.json")), true);
25
-        if($pluginJson) {
26
-            return version_compare($pluginJson['version'], $versionToCompare,"!=");
27
-        }else{
25
+        if ($pluginJson) {
26
+            return version_compare($pluginJson['version'], $versionToCompare, "!=");
27
+        } else {
28 28
             return false;
29 29
         }
30 30
     }
31 31
 
32 32
     public static function registerDefaultRoute($dir)
33 33
     {
34
-        Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
34
+        Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
35 35
             'prefix'=>"developer/".getSetting('developer_path'),
36
-            'namespace' => 'App\CBPlugins\\'.basename(dirname("./../".$dir)).'\Controllers'], function () use ($dir) {
37
-            cb()->routeController("plugins/".basename(dirname("./../".$dir)),"\App\CBPlugins\\".basename(dirname("./../".$dir))."\Controllers\\".basename(dirname("./../".$dir))."Controller");
36
+            'namespace' => 'App\CBPlugins\\'.basename(dirname("./../".$dir)).'\Controllers'], function() use ($dir) {
37
+            cb()->routeController("plugins/".basename(dirname("./../".$dir)), "\App\CBPlugins\\".basename(dirname("./../".$dir))."\Controllers\\".basename(dirname("./../".$dir))."Controller");
38 38
         });
39 39
     }
40 40
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
         $plugins_from_master = $this->getAll(__DIR__."/../views/themes");
44 44
         $result = [];
45 45
         $plugins = array_merge($plugins_from_master, $plugins_from_user);
46
-        foreach($plugins as $plugin) {
47
-            if($plugin['type'] == "theme") {
46
+        foreach ($plugins as $plugin) {
47
+            if ($plugin['type'] == "theme") {
48 48
                 $result[] = $plugin;
49 49
             }
50 50
         }
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function getAll($path = null)
55 55
     {
56
-        $path = ($path)?:app_path("CBPlugins");
56
+        $path = ($path) ?: app_path("CBPlugins");
57 57
         $plugins = scandir($path);
58 58
 
59 59
         $result = [];
60
-        foreach($plugins as $plugin) {
61
-            if($plugin != "." && $plugin != "..") {
60
+        foreach ($plugins as $plugin) {
61
+            if ($plugin != "." && $plugin != "..") {
62 62
                 $basename = basename($plugin);
63 63
                 $row = json_decode(file_get_contents($path.DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR."plugin.json"), true);
64
-                if($row) {
64
+                if ($row) {
65 65
                     try {
66 66
                         $row['url'] = route($basename."ControllerGetIndex");
67 67
                     } catch (\Exception $e) {
Please login to merge, or discard this patch.
src/routes.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,59 +1,59 @@  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'=>"developer/".getSetting('developer_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()->routeController("plugins","\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController");
12
-    cb()->routeController("mail","\crocodicstudio\crudbooster\controllers\DeveloperMailController");
13
-    cb()->routeController("security","\crocodicstudio\crudbooster\controllers\DeveloperSecurityController");
14
-    cb()->routeController("themes","\crocodicstudio\crudbooster\controllers\DeveloperThemesController");
15
-    cb()->routeController("appearance","\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController");
16
-    cb()->routeController("miscellaneous","\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController");
17
-    cb()->routePost("skip-tutorial","DeveloperDashboardController@postSkipTutorial");
18
-    cb()->routeGet("/","DeveloperDashboardController@getIndex");
9
+    cb()->routeController("roles", "\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
+    cb()->routeController("users", "\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
+    cb()->routeController("plugins", "\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController");
12
+    cb()->routeController("mail", "\crocodicstudio\crudbooster\controllers\DeveloperMailController");
13
+    cb()->routeController("security", "\crocodicstudio\crudbooster\controllers\DeveloperSecurityController");
14
+    cb()->routeController("themes", "\crocodicstudio\crudbooster\controllers\DeveloperThemesController");
15
+    cb()->routeController("appearance", "\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController");
16
+    cb()->routeController("miscellaneous", "\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController");
17
+    cb()->routePost("skip-tutorial", "DeveloperDashboardController@postSkipTutorial");
18
+    cb()->routeGet("/", "DeveloperDashboardController@getIndex");
19 19
 });
20 20
 
21 21
 // Developer Auth Middleware
22 22
 Route::group(['middleware' => ['web'],
23 23
     'prefix'=>"developer/".getSetting('developer_path'),
24
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
25
-    cb()->routePost("login","AdminAuthController@postLoginDeveloper");
26
-    cb()->routeGet("login","AdminAuthController@getLoginDeveloper");
27
-    cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper");
24
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
25
+    cb()->routePost("login", "AdminAuthController@postLoginDeveloper");
26
+    cb()->routeGet("login", "AdminAuthController@getLoginDeveloper");
27
+    cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper");
28 28
 });
29 29
 
30 30
 // Routing without any middleware
31
-Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () {
32
-    if(getSetting("AUTO_REDIRECT_TO_LOGIN")) {
33
-        cb()->routeGet("/","AdminAuthController@getRedirectToLogin");
31
+Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() {
32
+    if (getSetting("AUTO_REDIRECT_TO_LOGIN")) {
33
+        cb()->routeGet("/", "AdminAuthController@getRedirectToLogin");
34 34
     }
35 35
 });
36 36
 
37 37
 // Routing without any middleware with admin prefix
38
-Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
38
+Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
39 39
     cb()->routeGet('logout', "AdminAuthController@getLogout");
40 40
 
41
-    if(!getSetting("DISABLE_LOGIN")) {
41
+    if (!getSetting("DISABLE_LOGIN")) {
42 42
         cb()->routePost('login', "AdminAuthController@postLogin");
43 43
         cb()->routeGet('login', "AdminAuthController@getLogin");
44 44
     }
45 45
 
46
-    if(getSetting("enable_forget")) {
47
-        cb()->routePost("forget","AdminAuthController@postForget");
46
+    if (getSetting("enable_forget")) {
47
+        cb()->routePost("forget", "AdminAuthController@postForget");
48 48
     }
49 49
 
50
-    if(getSetting("enable_register")) {
51
-        cb()->routePost("register","AdminAuthController@postRegister");
50
+    if (getSetting("enable_register")) {
51
+        cb()->routePost("register", "AdminAuthController@postRegister");
52 52
     }
53 53
 });
54 54
 
55 55
 // Routing package controllers
56
-cb()->routeGroupBackend(function () {
56
+cb()->routeGroupBackend(function() {
57 57
     cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController');
58 58
 });
59 59
 
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
     'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class],
63 63
     'prefix' => cb()->getAdminPath(),
64 64
     'namespace' => 'App\Http\Controllers',
65
-], function () {
65
+], function() {
66 66
 
67 67
     if (Request::is(cb()->getAdminPath())) {
68
-        if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
68
+        if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
69 69
             cb()->routeGet("/", $dashboard);
70
-        }else{
70
+        } else {
71 71
             cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex");
72 72
         }
73 73
     }
74 74
 
75 75
     $controllers = glob(app_path('Http/Controllers/Admin*Controller.php'));
76 76
 
77
-    foreach($controllers as $controller) {
77
+    foreach ($controllers as $controller) {
78 78
         $controllerName = basename($controller);
79
-        $controllerName = rtrim($controllerName,".php");
79
+        $controllerName = rtrim($controllerName, ".php");
80 80
         $className = '\App\Http\Controllers\\'.$controllerName;
81 81
         $controllerClass = new $className();
82
-        if(method_exists($controllerClass, 'cbInit')) {
82
+        if (method_exists($controllerClass, 'cbInit')) {
83 83
             cb()->routeController($controllerClass->getData('permalink'), $controllerName);
84 84
         }
85 85
     }
Please login to merge, or discard this patch.
src/controllers/DeveloperThemesController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@
 block discarded – undo
20 20
         $themes = (new Plugin())->getAllThemes();
21 21
         $data = [];
22 22
         $data['result'] = $themes;
23
-        return view($this->view.".index",$data);
23
+        return view($this->view.".index", $data);
24 24
     }
25 25
 
26 26
     public function getActiveTheme($theme_path) {
27 27
         $theme_path = base64_decode($theme_path);
28 28
         putSetting("theme_path", $theme_path);
29
-        return cb()->redirectBack("Theme has been activated!","success");
29
+        return cb()->redirectBack("Theme has been activated!", "success");
30 30
     }
31 31
 
32 32
     public function postSaveConfig() {
33 33
 
34
-        foreach(request()->except("_token") as $key=>$val) {
35
-            putSetting( $key,  $val);
34
+        foreach (request()->except("_token") as $key=>$val) {
35
+            putSetting($key, $val);
36 36
         }
37 37
 
38
-        return cb()->redirectBack("Theme config has been saved!","success");
38
+        return cb()->redirectBack("Theme config has been saved!", "success");
39 39
     }
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
src/controllers/AdminProfileController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
     public function getIndex() {
12 12
         $data = [];
13 13
         $data['page_title'] = cbLang("profile");
14
-        return view(getThemePath('profile'),$data);
14
+        return view(getThemePath('profile'), $data);
15 15
     }
16 16
 
17 17
     public function postUpdate() {
18
-        validator(request()->all(),[
18
+        validator(request()->all(), [
19 19
             'name'=>'required|max:255|min:3',
20 20
             'email'=>'required|email',
21 21
             'photo'=>'image',
@@ -26,20 +26,20 @@  discard block
 block discarded – undo
26 26
             $data = [];
27 27
             $data['name'] = request('name');
28 28
             $data['email'] = request('email');
29
-            if(request('password')) {
29
+            if (request('password')) {
30 30
                 $data['password'] = Hash::make(request('password'));
31 31
             }
32
-            if(request()->hasFile('photo')) {
32
+            if (request()->hasFile('photo')) {
33 33
                 $data['photo'] = cb()->uploadFile('photo', true, 200, 200);
34 34
             }
35 35
 
36 36
             DB::table("users")->where("id", auth()->id())->update($data);
37
-        }catch (\Exception $e) {
37
+        } catch (\Exception $e) {
38 38
             Log::error($e);
39
-            return cb()->redirectBack(cbLang("something_went_wrong"),"warning");
39
+            return cb()->redirectBack(cbLang("something_went_wrong"), "warning");
40 40
         }
41 41
 
42
-        return cb()->redirectBack("The profile data has been updated!","success");
42
+        return cb()->redirectBack("The profile data has been updated!", "success");
43 43
     }
44 44
 
45 45
 }
Please login to merge, or discard this patch.
src/middlewares/CBBackend.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
      */
19 19
     public function handle($request, Closure $next)
20 20
     {
21
-        if(auth()->guest()) {
22
-            return cb()->redirect(cb()->getLoginUrl("login"),cbLang('please_login_for_first'),'warning');
21
+        if (auth()->guest()) {
22
+            return cb()->redirect(cb()->getLoginUrl("login"), cbLang('please_login_for_first'), 'warning');
23 23
         }
24 24
 
25 25
         (new CBHook())->beforeBackendMiddleware($request);
Please login to merge, or discard this patch.
src/helpers/SidebarMenus.php 1 patch
Spacing   +20 added lines, -20 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);
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
             $model->setBasepath(config('crudbooster.ADMIN_PATH').'/'.basename($model->getUrl()));
47 47
         }
48 48
 
49
-        if(request()->is($model->getBasepath()."*")) {
49
+        if (request()->is($model->getBasepath()."*")) {
50 50
             $model->setIsActive(true);
51
-        }else{
51
+        } else {
52 52
             $model->setIsActive(false);
53 53
         }
54 54
 
@@ -57,22 +57,22 @@  discard block
 block discarded – undo
57 57
 
58 58
     private function loadData($parent_id = null) {
59 59
         $menus = DB::table("cb_menus");
60
-        if($parent_id) {
61
-            $menus->where("parent_cb_menus_id",$parent_id);
62
-        }else{
60
+        if ($parent_id) {
61
+            $menus->where("parent_cb_menus_id", $parent_id);
62
+        } else {
63 63
             $menus->whereNull("parent_cb_menus_id");
64 64
         }
65
-        return $menus->orderBy("sort_number","asc")->get();
65
+        return $menus->orderBy("sort_number", "asc")->get();
66 66
     }
67 67
 
68 68
     private function rolePrivilege($cb_roles_id, $cb_menus_id) {
69
-        return cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id]);
69
+        return cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id]);
70 70
     }
71 71
 
72
-    private function checkPrivilege($roles_id,$menu) {
73
-        if($roles_id) {
72
+    private function checkPrivilege($roles_id, $menu) {
73
+        if ($roles_id) {
74 74
             $privilege = $this->rolePrivilege($roles_id, $menu->id);
75
-            if($privilege && !$privilege->can_browse) {
75
+            if ($privilege && !$privilege->can_browse) {
76 76
                 return false;
77 77
             }
78 78
         }
@@ -81,30 +81,30 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
     public function all($withPrivilege = true) {
84
-        $roles_id = ($withPrivilege)?cb()->session()->roleId():null;
84
+        $roles_id = ($withPrivilege) ?cb()->session()->roleId() : null;
85 85
         $idHash = "menuUser".$roles_id.auth()->id();
86
-        if($menu = CacheHelper::getItemInGroup($idHash,"sidebar_menu")) return $menu;
86
+        if ($menu = CacheHelper::getItemInGroup($idHash, "sidebar_menu")) return $menu;
87 87
 
88 88
         $menus = $this->loadData();
89 89
         $result = [];
90
-        foreach($menus as $menu) {
90
+        foreach ($menus as $menu) {
91 91
 
92
-            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
92
+            if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
93 93
 
94 94
             $sidebarModel = $this->assignToModel($menu);
95
-            if($menus2 = $this->loadData($menu->id)) {
95
+            if ($menus2 = $this->loadData($menu->id)) {
96 96
                 $sub1 = [];
97 97
                 foreach ($menus2 as $menu2) {
98 98
 
99
-                    if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
99
+                    if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
100 100
 
101 101
                     $sidebarModel2 = $this->assignToModel($menu2);
102 102
 
103
-                    if($menus3 = $this->loadData($menu2->id)) {
103
+                    if ($menus3 = $this->loadData($menu2->id)) {
104 104
                         $sub2 = [];
105 105
                         foreach ($menus3 as $menu3) {
106 106
 
107
-                            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
107
+                            if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
108 108
 
109 109
                             $sidebarModel3 = $this->assignToModel($menu3);
110 110
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             $result[] = $sidebarModel;
120 120
         }
121 121
 
122
-        CacheHelper::putInGroup($idHash, $result,"sidebar_menu", 3600);
122
+        CacheHelper::putInGroup($idHash, $result, "sidebar_menu", 3600);
123 123
         return $result;
124 124
     }
125 125
 
Please login to merge, or discard this patch.
src/helpers/CB.php 1 patch
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 getDeveloperPath($path = null) {
43
-        $path = ($path)?"/".trim($path,"/"):null;
43
+        $path = ($path) ? "/".trim($path, "/") : null;
44 44
         return "developer/".getSetting("developer_path").$path;
45 45
     }
46 46
 
@@ -61,16 +61,16 @@  discard block
 block discarded – undo
61 61
     }
62 62
 
63 63
     public function getAdminPath() {
64
-        return getSetting("ADMIN_PATH","admin");
64
+        return getSetting("ADMIN_PATH", "admin");
65 65
     }
66 66
 
67 67
     public function getAdminUrl($path = null) {
68
-        $path = ($path)?"/".trim($path,"/"):null;
68
+        $path = ($path) ? "/".trim($path, "/") : null;
69 69
         return url($this->getAdminPath()).$path;
70 70
     }
71 71
 
72 72
     public function getAppName() {
73
-        return getSetting("APP_NAME", env("APP_NAME","CRUDBOOSTER"));
73
+        return getSetting("APP_NAME", env("APP_NAME", "CRUDBOOSTER"));
74 74
     }
75 75
 
76 76
     /**
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function uploadFileProcess($filename, $extension, $file, $encrypt = true, $resize_width = null, $resize_height = null)
86 86
     {
87
-        if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
87
+        if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
88 88
             $file_path = cbConfig("UPLOAD_PATH_FORMAT");
89
-            $file_path = str_replace("{Y}",date('Y'), $file_path);
89
+            $file_path = str_replace("{Y}", date('Y'), $file_path);
90 90
             $file_path = str_replace("{m}", date('m'), $file_path);
91 91
             $file_path = str_replace("{d}", date("d"), $file_path);
92 92
 
93 93
             //Create Directory Base On Template
94 94
             Storage::makeDirectory($file_path);
95
-            Storage::put($file_path."/index.html","&nbsp;","public");
96
-            Storage::put($file_path."/.gitignore","!.gitignore","public");
95
+            Storage::put($file_path."/index.html", "&nbsp;", "public");
96
+            Storage::put($file_path."/.gitignore", "!.gitignore", "public");
97 97
 
98 98
             if ($encrypt == true) {
99 99
                 $filename = md5(strRandom(5)).'.'.$extension;
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
                 $filename = slug($filename, '_').'.'.$extension;
102 102
             }
103 103
 
104
-            if($resize_width || $resize_height) {
104
+            if ($resize_width || $resize_height) {
105 105
                 $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height);
106 106
                 return $file_path.'/'.$filename;
107
-            }else{
107
+            } else {
108 108
                 if (Storage::putFileAs($file_path, $file, $filename, 'public')) {
109 109
                     return $file_path.'/'.$filename;
110 110
                 } else {
111 111
                     throw new \Exception("Something went wrong, file can't upload!");
112 112
                 }
113 113
             }
114
-        }else{
114
+        } else {
115 115
             throw new \Exception("The file format is not allowed!");
116 116
         }
117 117
     }
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $fileData = base64_decode($base64_value);
129 129
         $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE);
130
-        if($mime_type) {
131
-            if($mime_type = explode('/', $mime_type)) {
130
+        if ($mime_type) {
131
+            if ($mime_type = explode('/', $mime_type)) {
132 132
                 $ext = $mime_type[1];
133
-                if($filename && $ext) {
133
+                if ($filename && $ext) {
134 134
                     return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height);
135 135
                 }
136
-            }else {
136
+            } else {
137 137
                 throw new \Exception("Mime type not found");
138 138
             }
139
-        }else{
139
+        } else {
140 140
             throw new \Exception("Mime type not found");
141 141
         }
142 142
     }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             $filename = $file->getClientOriginalName();
157 157
             $ext = strtolower($file->getClientOriginalExtension());
158 158
 
159
-            if($filename && $ext) {
159
+            if ($filename && $ext) {
160 160
                 return $this->uploadFileProcess($filename, $ext, $file, $encrypt, $resize_width, $resize_height);
161 161
             }
162 162
 
@@ -191,29 +191,29 @@  discard block
 block discarded – undo
191 191
             if ($resize_width && $resize_height) {
192 192
                 $img->fit($resize_width, $resize_height);
193 193
 
194
-            } elseif ($resize_width && ! $resize_height) {
194
+            } elseif ($resize_width && !$resize_height) {
195 195
 
196
-                $img->resize($resize_width, null, function ($constraint) {
196
+                $img->resize($resize_width, null, function($constraint) {
197 197
                     $constraint->aspectRatio();
198 198
                 });
199 199
 
200
-            } elseif (! $resize_width && $resize_height) {
200
+            } elseif (!$resize_width && $resize_height) {
201 201
 
202
-                $img->resize(null, $resize_height, function ($constraint) {
202
+                $img->resize(null, $resize_height, function($constraint) {
203 203
                     $constraint->aspectRatio();
204 204
                 });
205 205
 
206 206
             } else {
207 207
 
208 208
                 if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) {
209
-                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) {
209
+                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) {
210 210
                         $constraint->aspectRatio();
211 211
                     });
212 212
                 }
213 213
             }
214 214
 
215 215
             Storage::put($fullFilePath, $img, 'public');
216
-        }else{
216
+        } else {
217 217
             throw new \Exception("The file format is not allowed!");
218 218
         }
219 219
     }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
     {
238 238
         if (is_array($id)) {
239 239
             $idHash = md5("find".$table.serialize($id));
240
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
240
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
241 241
 
242 242
             $first = DB::table($table);
243 243
             foreach ($id as $k => $v) {
@@ -245,15 +245,15 @@  discard block
 block discarded – undo
245 245
             }
246 246
 
247 247
             $data = $first->first();
248
-            miscellanousSingleton()->setData($idHash,$data);
248
+            miscellanousSingleton()->setData($idHash, $data);
249 249
             return $data;
250 250
         } else {
251 251
             $idHash = md5("find".$table.$id);
252
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
252
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
253 253
 
254 254
             $pk = $this->pk($table);
255 255
             $data = DB::table($table)->where($pk, $id)->first();
256
-            miscellanousSingleton()->setData($idHash,$data);
256
+            miscellanousSingleton()->setData($idHash, $data);
257 257
             return $data;
258 258
         }
259 259
     }
@@ -268,30 +268,30 @@  discard block
 block discarded – undo
268 268
         $data = [];
269 269
         $idHash = null;
270 270
 
271
-        if(is_array($conditionOrCallback)) {
271
+        if (is_array($conditionOrCallback)) {
272 272
             $idHash = md5("findAll".$table.serialize($conditionOrCallback));
273
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
273
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
274 274
 
275 275
             $data = DB::table($table)->where($conditionOrCallback)->get();
276 276
         } elseif (is_callable($conditionOrCallback)) {
277 277
             $idHash = "findAll".$table.spl_object_hash($conditionOrCallback);
278
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
278
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
279 279
 
280 280
             $data = DB::table($table);
281 281
             $data = call_user_func($conditionOrCallback, $data);
282 282
             $data = $data->get();
283 283
         } else {
284 284
             $idHash = md5("findAll".$table.$conditionOrCallback);
285
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
285
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
286 286
 
287 287
             $data = DB::table($table);
288
-            if($conditionOrCallback) {
288
+            if ($conditionOrCallback) {
289 289
                 $data = $data->whereRaw($conditionOrCallback);
290 290
             }
291 291
             $data = $data->get();
292 292
         }
293 293
 
294
-        if($idHash && $data) {
294
+        if ($idHash && $data) {
295 295
             miscellanousSingleton()->setData($idHash, $data);
296 296
         }
297 297
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
     public function listAllTable()
302 302
     {
303 303
         $idHash = md5("listAllTable");
304
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
304
+        if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
305 305
         $data = DB::connection()->getDoctrineSchemaManager()->listTableNames();
306 306
         miscellanousSingleton()->setData($idHash, $data);
307 307
         return $data;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     public function listAllColumns($table)
311 311
     {
312 312
         $idHash = md5("listAllColumns".$table);
313
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
313
+        if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
314 314
         $data = Schema::getColumnListing($table);
315 315
         miscellanousSingleton()->setData($idHash, $data);
316 316
         return $data;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
         $validator = Validator::make($input_arr, $rules, $messages);
379 379
         if ($validator->fails()) {
380 380
             $message = $validator->errors()->all();
381
-            throw new CBValidationException(implode("; ",$message));
381
+            throw new CBValidationException(implode("; ", $message));
382 382
         }
383 383
     }
384 384
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
     public function findPrimaryKey($table)
391 391
     {
392 392
         $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
393
-        if(!$pk) {
393
+        if (!$pk) {
394 394
             return null;
395 395
         }
396 396
         return $pk->getColumns()[0];
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             $string_parameters_array = explode('&', $string_parameters);
440 440
             foreach ($string_parameters_array as $s) {
441 441
                 $part = explode('=', $s);
442
-                if(isset($part[0]) && isset($part[1])) {
442
+                if (isset($part[0]) && isset($part[1])) {
443 443
                     $name = htmlspecialchars(urldecode($part[0]));
444 444
                     $name = strip_tags($name);
445 445
                     $value = htmlspecialchars(urldecode($part[1]));
@@ -456,16 +456,16 @@  discard block
 block discarded – undo
456 456
 
457 457
 
458 458
     public function routeGet($prefix, $controller) {
459
-        $alias = str_replace("@"," ", $controller);
459
+        $alias = str_replace("@", " ", $controller);
460 460
         $alias = ucwords($alias);
461
-        $alias = str_replace(" ","",$alias);
461
+        $alias = str_replace(" ", "", $alias);
462 462
         Route::get($prefix, ['uses' => $controller, 'as' => $alias]);
463 463
     }
464 464
 
465 465
     public function routePost($prefix, $controller) {
466
-        $alias = str_replace("@"," ", $controller);
466
+        $alias = str_replace("@", " ", $controller);
467 467
         $alias = ucwords($alias);
468
-        $alias = str_replace(" ","",$alias);
468
+        $alias = str_replace(" ", "", $alias);
469 469
         Route::post($prefix, ['uses' => $controller, 'as' => $alias]);
470 470
     }
471 471
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 
499 499
         $prefix = trim($prefix, '/').'/';
500 500
 
501
-        if(substr($controller,0,1) != "\\") {
501
+        if (substr($controller, 0, 1) != "\\") {
502 502
             $controller = "\App\Http\Controllers\\".$controller;
503 503
         }
504 504
 
Please login to merge, or discard this patch.