@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | // Register views |
26 | 26 | $this->loadViewsFrom(__DIR__.'/views', 'crudbooster'); |
27 | 27 | $this->loadViewsFrom(__DIR__.'/types', 'types'); |
28 | - $this->loadTranslationsFrom(__DIR__."/localization","cb"); |
|
28 | + $this->loadTranslationsFrom(__DIR__."/localization", "cb"); |
|
29 | 29 | |
30 | 30 | // Publish the files |
31 | - $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')],'cb_config'); |
|
32 | - $this->publishes([__DIR__.'/database' => base_path('database')],'cb_migration'); |
|
33 | - $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')],'cb_hook'); |
|
34 | - $this->publishes([__DIR__ . '/assets' =>public_path('cb_asset')],'cb_asset'); |
|
31 | + $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config'); |
|
32 | + $this->publishes([__DIR__.'/database' => base_path('database')], 'cb_migration'); |
|
33 | + $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')], 'cb_hook'); |
|
34 | + $this->publishes([__DIR__.'/assets' =>public_path('cb_asset')], 'cb_asset'); |
|
35 | 35 | |
36 | 36 | // Override Local FileSystem |
37 | 37 | Config::set("filesystems.disks.local.root", cbConfig("LOCAL_FILESYSTEM_PATH", public_path("storage"))); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | require __DIR__.'/helpers/Helper.php'; |
54 | 54 | |
55 | 55 | // Singletons |
56 | - $this->app->singleton('crudbooster', function () |
|
56 | + $this->app->singleton('crudbooster', function() |
|
57 | 57 | { |
58 | 58 | return true; |
59 | 59 | }); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | // Merging configuration |
79 | - $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster'); |
|
79 | + $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster'); |
|
80 | 80 | |
81 | 81 | // Register additional library |
82 | 82 | $this->app->register('Intervention\Image\ImageServiceProvider'); |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | |
85 | 85 | private function registerPlugin() |
86 | 86 | { |
87 | - if(file_exists(app_path("CBPlugins"))) { |
|
87 | + if (file_exists(app_path("CBPlugins"))) { |
|
88 | 88 | $views = scandir(app_path("CBPlugins")); |
89 | - foreach($views as $view) { |
|
90 | - if($view != "." && $view != "..") { |
|
89 | + foreach ($views as $view) { |
|
90 | + if ($view != "." && $view != "..") { |
|
91 | 91 | $basename = basename($view); |
92 | 92 | |
93 | 93 | // register migrations |
94 | 94 | $this->loadMigrationsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Migrations")); |
95 | 95 | |
96 | 96 | // register view |
97 | - $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"),$basename); |
|
97 | + $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"), $basename); |
|
98 | 98 | |
99 | 99 | // register route |
100 | 100 | require app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Routes".DIRECTORY_SEPARATOR."Route.php"); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | private function registerTypeRoutes() { |
109 | 109 | $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php"); |
110 | - foreach($routes as $route) { |
|
110 | + foreach ($routes as $route) { |
|
111 | 111 | require $route; |
112 | 112 | } |
113 | 113 | } |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | try { |
27 | 27 | $routeArray = request()->route()->getAction(); |
28 | 28 | $this->controller = class_basename($routeArray['controller']); |
29 | - $this->controller = strtok($this->controller,"@"); |
|
29 | + $this->controller = strtok($this->controller, "@"); |
|
30 | 30 | |
31 | 31 | $className = "\\".$routeArray["namespace"]."\\".$this->controller; |
32 | - if(class_exists($className)) { |
|
33 | - $this->module = cb()->find("cb_modules",["controller"=>$this->controller]); |
|
34 | - if($this->module) { |
|
32 | + if (class_exists($className)) { |
|
33 | + $this->module = cb()->find("cb_modules", ["controller"=>$this->controller]); |
|
34 | + if ($this->module) { |
|
35 | 35 | $this->controller_class = new $className(); |
36 | - $this->menu = cb()->find("cb_menus",["cb_modules_id"=>$this->module->id]); |
|
37 | - $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu; |
|
38 | - if($this->menu) { |
|
39 | - $this->privilege = cb()->find("cb_role_privileges",[ |
|
36 | + $this->menu = cb()->find("cb_menus", ["cb_modules_id"=>$this->module->id]); |
|
37 | + $this->menu = (!$this->menu) ?cb()->find("cb_menus", ["type"=>"path", "path"=>request()->segment(2)]) : $this->menu; |
|
38 | + if ($this->menu) { |
|
39 | + $this->privilege = cb()->find("cb_role_privileges", [ |
|
40 | 40 | "cb_menus_id"=>$this->menu->id, |
41 | 41 | "cb_roles_id"=>cb()->session()->roleId() |
42 | 42 | ]); |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | public function getData($key) { |
60 | - if($this->controller_class) { |
|
60 | + if ($this->controller_class) { |
|
61 | 61 | $value = $this->controller_class->getData($key); |
62 | - if(isset($value)) { |
|
62 | + if (isset($value)) { |
|
63 | 63 | return $value; |
64 | 64 | } |
65 | 65 | } |
@@ -70,128 +70,128 @@ discard block |
||
70 | 70 | * @return CBController |
71 | 71 | */ |
72 | 72 | public function getController() { |
73 | - return ($this->controller_class)?$this->controller_class:null; |
|
73 | + return ($this->controller_class) ? $this->controller_class : null; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public function getPageTitle() |
77 | 77 | { |
78 | - return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null; |
|
78 | + return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function getTable() |
82 | 82 | { |
83 | - return ($this->controller_class)?$this->controller_class->getData("table"):null; |
|
83 | + return ($this->controller_class) ? $this->controller_class->getData("table") : null; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | public function getPageIcon() |
87 | 87 | { |
88 | - return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null; |
|
88 | + return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | public function canBrowse() { |
92 | - if($this->privilege) { |
|
93 | - if($this->privilege->can_browse) return true; |
|
92 | + if ($this->privilege) { |
|
93 | + if ($this->privilege->can_browse) return true; |
|
94 | 94 | else return false; |
95 | - }else{ |
|
95 | + } else { |
|
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | 100 | public function canCreate() { |
101 | - if($this->privilege) { |
|
102 | - if($this->privilege->can_create) return true; |
|
101 | + if ($this->privilege) { |
|
102 | + if ($this->privilege->can_create) return true; |
|
103 | 103 | else return false; |
104 | - }else{ |
|
104 | + } else { |
|
105 | 105 | return true; |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | 109 | public function canRead() { |
110 | - if($this->privilege) { |
|
111 | - if($this->privilege->can_read) return true; |
|
110 | + if ($this->privilege) { |
|
111 | + if ($this->privilege->can_read) return true; |
|
112 | 112 | else return false; |
113 | - }else{ |
|
113 | + } else { |
|
114 | 114 | return true; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | public function canUpdate() { |
119 | - if($this->privilege) { |
|
120 | - if($this->privilege->can_update) return true; |
|
119 | + if ($this->privilege) { |
|
120 | + if ($this->privilege->can_update) return true; |
|
121 | 121 | else return false; |
122 | - }else{ |
|
122 | + } else { |
|
123 | 123 | return true; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | 127 | public function canDelete() { |
128 | - if($this->privilege) { |
|
129 | - if($this->privilege->can_delete) return true; |
|
128 | + if ($this->privilege) { |
|
129 | + if ($this->privilege->can_delete) return true; |
|
130 | 130 | else return false; |
131 | - }else{ |
|
131 | + } else { |
|
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | 136 | public function addURL() |
137 | 137 | { |
138 | - if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
138 | + if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
139 | 139 | return action($this->controller.'@getAdd'); |
140 | - }else{ |
|
140 | + } else { |
|
141 | 141 | return null; |
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | public function addSaveURL() |
146 | 146 | { |
147 | - if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
147 | + if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
148 | 148 | return action($this->controller.'@postAddSave'); |
149 | - }else{ |
|
149 | + } else { |
|
150 | 150 | return null; |
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | 154 | public function editURL($id = null) |
155 | 155 | { |
156 | - if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
156 | + if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
157 | 157 | return action($this->controller.'@getEdit')."/".$id; |
158 | - }else{ |
|
158 | + } else { |
|
159 | 159 | return null; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | public function editSaveURL($id = null) |
164 | 164 | { |
165 | - if(method_exists($this->controller_class, 'postEditSave')) { |
|
165 | + if (method_exists($this->controller_class, 'postEditSave')) { |
|
166 | 166 | return action($this->controller.'@postEditSave')."/".$id; |
167 | - }else{ |
|
167 | + } else { |
|
168 | 168 | return null; |
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | - public function detailURL($id=null) |
|
172 | + public function detailURL($id = null) |
|
173 | 173 | { |
174 | - if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
174 | + if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
175 | 175 | return action($this->controller.'@getDetail')."/".$id; |
176 | - }else{ |
|
176 | + } else { |
|
177 | 177 | return null; |
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - public function deleteURL($id=null) |
|
181 | + public function deleteURL($id = null) |
|
182 | 182 | { |
183 | - if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
183 | + if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
184 | 184 | return action($this->controller.'@getDelete')."/".$id; |
185 | - }else{ |
|
185 | + } else { |
|
186 | 186 | return null; |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | public function url($path = null) |
191 | 191 | { |
192 | - if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
193 | - return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
|
194 | - }else{ |
|
192 | + if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
193 | + return trim(action($this->controller.'@getIndex').'/'.$path, '/'); |
|
194 | + } else { |
|
195 | 195 | return null; |
196 | 196 | } |
197 | 197 | } |
@@ -90,45 +90,60 @@ discard block |
||
90 | 90 | |
91 | 91 | public function canBrowse() { |
92 | 92 | if($this->privilege) { |
93 | - if($this->privilege->can_browse) return true; |
|
94 | - else return false; |
|
95 | - }else{ |
|
93 | + if($this->privilege->can_browse) { |
|
94 | + return true; |
|
95 | + } else { |
|
96 | + return false; |
|
97 | + } |
|
98 | + } else{ |
|
96 | 99 | return true; |
97 | 100 | } |
98 | 101 | } |
99 | 102 | |
100 | 103 | public function canCreate() { |
101 | 104 | if($this->privilege) { |
102 | - if($this->privilege->can_create) return true; |
|
103 | - else return false; |
|
104 | - }else{ |
|
105 | + if($this->privilege->can_create) { |
|
106 | + return true; |
|
107 | + } else { |
|
108 | + return false; |
|
109 | + } |
|
110 | + } else{ |
|
105 | 111 | return true; |
106 | 112 | } |
107 | 113 | } |
108 | 114 | |
109 | 115 | public function canRead() { |
110 | 116 | if($this->privilege) { |
111 | - if($this->privilege->can_read) return true; |
|
112 | - else return false; |
|
113 | - }else{ |
|
117 | + if($this->privilege->can_read) { |
|
118 | + return true; |
|
119 | + } else { |
|
120 | + return false; |
|
121 | + } |
|
122 | + } else{ |
|
114 | 123 | return true; |
115 | 124 | } |
116 | 125 | } |
117 | 126 | |
118 | 127 | public function canUpdate() { |
119 | 128 | if($this->privilege) { |
120 | - if($this->privilege->can_update) return true; |
|
121 | - else return false; |
|
122 | - }else{ |
|
129 | + if($this->privilege->can_update) { |
|
130 | + return true; |
|
131 | + } else { |
|
132 | + return false; |
|
133 | + } |
|
134 | + } else{ |
|
123 | 135 | return true; |
124 | 136 | } |
125 | 137 | } |
126 | 138 | |
127 | 139 | public function canDelete() { |
128 | 140 | if($this->privilege) { |
129 | - if($this->privilege->can_delete) return true; |
|
130 | - else return false; |
|
131 | - }else{ |
|
141 | + if($this->privilege->can_delete) { |
|
142 | + return true; |
|
143 | + } else { |
|
144 | + return false; |
|
145 | + } |
|
146 | + } else{ |
|
132 | 147 | return true; |
133 | 148 | } |
134 | 149 | } |
@@ -137,7 +152,7 @@ discard block |
||
137 | 152 | { |
138 | 153 | if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
139 | 154 | return action($this->controller.'@getAdd'); |
140 | - }else{ |
|
155 | + } else{ |
|
141 | 156 | return null; |
142 | 157 | } |
143 | 158 | } |
@@ -146,7 +161,7 @@ discard block |
||
146 | 161 | { |
147 | 162 | if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
148 | 163 | return action($this->controller.'@postAddSave'); |
149 | - }else{ |
|
164 | + } else{ |
|
150 | 165 | return null; |
151 | 166 | } |
152 | 167 | } |
@@ -155,7 +170,7 @@ discard block |
||
155 | 170 | { |
156 | 171 | if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
157 | 172 | return action($this->controller.'@getEdit')."/".$id; |
158 | - }else{ |
|
173 | + } else{ |
|
159 | 174 | return null; |
160 | 175 | } |
161 | 176 | } |
@@ -164,7 +179,7 @@ discard block |
||
164 | 179 | { |
165 | 180 | if(method_exists($this->controller_class, 'postEditSave')) { |
166 | 181 | return action($this->controller.'@postEditSave')."/".$id; |
167 | - }else{ |
|
182 | + } else{ |
|
168 | 183 | return null; |
169 | 184 | } |
170 | 185 | } |
@@ -173,7 +188,7 @@ discard block |
||
173 | 188 | { |
174 | 189 | if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
175 | 190 | return action($this->controller.'@getDetail')."/".$id; |
176 | - }else{ |
|
191 | + } else{ |
|
177 | 192 | return null; |
178 | 193 | } |
179 | 194 | } |
@@ -182,7 +197,7 @@ discard block |
||
182 | 197 | { |
183 | 198 | if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
184 | 199 | return action($this->controller.'@getDelete')."/".$id; |
185 | - }else{ |
|
200 | + } else{ |
|
186 | 201 | return null; |
187 | 202 | } |
188 | 203 | } |
@@ -191,7 +206,7 @@ discard block |
||
191 | 206 | { |
192 | 207 | if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
193 | 208 | return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
194 | - }else{ |
|
209 | + } else{ |
|
195 | 210 | return null; |
196 | 211 | } |
197 | 212 | } |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | |
26 | 26 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
27 | 27 | |
28 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
29 | - if($softDelete === true && SchemaHelper::hasColumn($this->data['table'],'deleted_at')) { |
|
28 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
29 | + if ($softDelete === true && SchemaHelper::hasColumn($this->data['table'], 'deleted_at')) { |
|
30 | 30 | $query->whereNull($this->data['table'].'.deleted_at'); |
31 | 31 | } |
32 | 32 | |
33 | - if(isset($joins)) { |
|
34 | - foreach($joins as $join) |
|
33 | + if (isset($joins)) { |
|
34 | + foreach ($joins as $join) |
|
35 | 35 | { |
36 | 36 | $query->join($join['target_table'], |
37 | 37 | $join['target_table_primary'], |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - foreach($columns as $column) { |
|
44 | + foreach ($columns as $column) { |
|
45 | 45 | /** @var ColumnModel $column */ |
46 | - if($column->getType() != "custom") { |
|
47 | - if(strpos($column->getField(),".") === false) { |
|
48 | - if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
46 | + if ($column->getType() != "custom") { |
|
47 | + if (strpos($column->getField(), ".") === false) { |
|
48 | + if (SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
49 | 49 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
50 | 50 | } |
51 | - }else{ |
|
51 | + } else { |
|
52 | 52 | $query->addSelect($column->getField()); |
53 | 53 | } |
54 | 54 | } |
@@ -57,27 +57,27 @@ discard block |
||
57 | 57 | $query = getTypeHook($column->getType())->query($query, $column); |
58 | 58 | |
59 | 59 | // Filter Query From Type |
60 | - $filterValue = request("filter_".slug($column->getFilterColumn(),"_")); |
|
61 | - if(is_array($filterValue) || sanitizeXSS($filterValue)) { |
|
60 | + $filterValue = request("filter_".slug($column->getFilterColumn(), "_")); |
|
61 | + if (is_array($filterValue) || sanitizeXSS($filterValue)) { |
|
62 | 62 | $query = getTypeHook($column->getType())->filterQuery($query, $column, $filterValue); |
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - if(request()->has('q')) |
|
66 | + if (request()->has('q')) |
|
67 | 67 | { |
68 | 68 | $keyword = sanitizeXSS(request("q")); |
69 | - if(isset($this->data['hook_search_query'])) { |
|
69 | + if (isset($this->data['hook_search_query'])) { |
|
70 | 70 | $query = call_user_func($this->data['hook_search_query'], $query, $keyword); |
71 | - }else{ |
|
72 | - $query->where(function ($where) use ($columns, $keyword) { |
|
71 | + } else { |
|
72 | + $query->where(function($where) use ($columns, $keyword) { |
|
73 | 73 | /** |
74 | 74 | * @var $where Builder |
75 | 75 | */ |
76 | - foreach($columns as $column) |
|
76 | + foreach ($columns as $column) |
|
77 | 77 | { |
78 | - if(strpos($column->getField(),".") === false) { |
|
78 | + if (strpos($column->getField(), ".") === false) { |
|
79 | 79 | $field = $this->data['table'].'.'.$column->getField(); |
80 | - }else{ |
|
80 | + } else { |
|
81 | 81 | $field = $column->getField(); |
82 | 82 | } |
83 | 83 | $where->orWhere($field, 'like', '%'.$keyword.'%'); |
@@ -90,36 +90,36 @@ discard block |
||
90 | 90 | /* |
91 | 91 | * This script to hanlde the callback inputed on this query method |
92 | 92 | */ |
93 | - if(isset($callback) && is_callable($callback)) { |
|
93 | + if (isset($callback) && is_callable($callback)) { |
|
94 | 94 | $query = call_user_func($callback, $query); |
95 | 95 | } |
96 | 96 | |
97 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
97 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
98 | 98 | $query = call_user_func($this->data['hook_index_query'], $query); |
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | - if(request()->has(['order_by','order_sort'])) |
|
102 | + if (request()->has(['order_by', 'order_sort'])) |
|
103 | 103 | { |
104 | - $sort = (request("order_sort")=="asc")?"asc":"desc"; |
|
104 | + $sort = (request("order_sort") == "asc") ? "asc" : "desc"; |
|
105 | 105 | /* |
106 | 106 | * Check if order by contain "." it means {table}.{column} we have to parsing that |
107 | 107 | */ |
108 | - if(strpos(request("order_by"), ".")!==false) { |
|
109 | - $orderByTable = explode(".",request("order_by"))[0]; |
|
110 | - $orderByColumn = explode(".",request("order_by"))[1]; |
|
111 | - if(SchemaHelper::hasColumn($orderByTable, $orderByColumn)) { |
|
108 | + if (strpos(request("order_by"), ".") !== false) { |
|
109 | + $orderByTable = explode(".", request("order_by"))[0]; |
|
110 | + $orderByColumn = explode(".", request("order_by"))[1]; |
|
111 | + if (SchemaHelper::hasColumn($orderByTable, $orderByColumn)) { |
|
112 | 112 | $query->orderBy($orderByTable.".".$orderByColumn, $sort); |
113 | 113 | } |
114 | 114 | } else { |
115 | 115 | /* |
116 | 116 | * Check if order_by column in registered columns |
117 | 117 | */ |
118 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
118 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
119 | 119 | $query->orderBy(request('order_by'), request('order_sort')); |
120 | 120 | } |
121 | 121 | } |
122 | - }else{ |
|
122 | + } else { |
|
123 | 123 | /* |
124 | 124 | * For default, query will be order by primary key as descending |
125 | 125 | */ |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
49 | 49 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
50 | 50 | } |
51 | - }else{ |
|
51 | + } else{ |
|
52 | 52 | $query->addSelect($column->getField()); |
53 | 53 | } |
54 | 54 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $keyword = sanitizeXSS(request("q")); |
69 | 69 | if(isset($this->data['hook_search_query'])) { |
70 | 70 | $query = call_user_func($this->data['hook_search_query'], $query, $keyword); |
71 | - }else{ |
|
71 | + } else{ |
|
72 | 72 | $query->where(function ($where) use ($columns, $keyword) { |
73 | 73 | /** |
74 | 74 | * @var $where Builder |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | if(strpos($column->getField(),".") === false) { |
79 | 79 | $field = $this->data['table'].'.'.$column->getField(); |
80 | - }else{ |
|
80 | + } else{ |
|
81 | 81 | $field = $column->getField(); |
82 | 82 | } |
83 | 83 | $where->orWhere($field, 'like', '%'.$keyword.'%'); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $query->orderBy(request('order_by'), request('order_sort')); |
120 | 120 | } |
121 | 121 | } |
122 | - }else{ |
|
122 | + } else{ |
|
123 | 123 | /* |
124 | 124 | * For default, query will be order by primary key as descending |
125 | 125 | */ |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | public function headers(array $headers) { |
51 | 51 | $newHeaders = []; |
52 | - foreach($headers as $key=>$val) { |
|
52 | + foreach ($headers as $key=>$val) { |
|
53 | 53 | $newHeaders[] = $key.": ".$val; |
54 | 54 | } |
55 | 55 | $this->headers = $newHeaders; |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
69 | 69 | curl_setopt($ch, CURLOPT_POSTFIELDS, $this->data); |
70 | 70 | curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); |
71 | - curl_setopt($ch,CURLOPT_USERAGENT,$this->user_agent); |
|
71 | + curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); |
|
72 | 72 | curl_setopt($ch, CURLOPT_REFERER, $this->referer); |
73 | - if($this->cookie === true) { |
|
73 | + if ($this->cookie === true) { |
|
74 | 74 | $cookie_dir = storage_path("cookies"); |
75 | - if(!file_exists($cookie_dir)) mkdir($cookie_dir); |
|
75 | + if (!file_exists($cookie_dir)) mkdir($cookie_dir); |
|
76 | 76 | $cookie_file = $cookie_dir."/".md5(request()->ip()).".txt"; |
77 | 77 | curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); |
78 | 78 | curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | $err = curl_error($ch); |
83 | 83 | curl_close($ch); |
84 | 84 | |
85 | - if($err) { |
|
85 | + if ($err) { |
|
86 | 86 | return $err; |
87 | - }else { |
|
87 | + } else { |
|
88 | 88 | return $response; |
89 | 89 | } |
90 | 90 | } |
@@ -72,7 +72,9 @@ discard block |
||
72 | 72 | curl_setopt($ch, CURLOPT_REFERER, $this->referer); |
73 | 73 | if($this->cookie === true) { |
74 | 74 | $cookie_dir = storage_path("cookies"); |
75 | - if(!file_exists($cookie_dir)) mkdir($cookie_dir); |
|
75 | + if(!file_exists($cookie_dir)) { |
|
76 | + mkdir($cookie_dir); |
|
77 | + } |
|
76 | 78 | $cookie_file = $cookie_dir."/".md5(request()->ip()).".txt"; |
77 | 79 | curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); |
78 | 80 | curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); |
@@ -84,7 +86,7 @@ discard block |
||
84 | 86 | |
85 | 87 | if($err) { |
86 | 88 | return $err; |
87 | - }else { |
|
89 | + } else { |
|
88 | 90 | return $response; |
89 | 91 | } |
90 | 92 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | 'Content-Type:application/json', |
69 | 69 | ]; |
70 | 70 | |
71 | - if(static::$title && $this->message) { |
|
71 | + if (static::$title && $this->message) { |
|
72 | 72 | $ch = curl_init($url); |
73 | 73 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
74 | 74 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |