@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | public function getIndex() { |
12 | 12 | $data = []; |
13 | 13 | $data['page_title'] = 'Profile'; |
14 | - return view('crudbooster::profile',$data); |
|
14 | + return view('crudbooster::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,19 +26,19 @@ discard block |
||
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 | DB::table("users")->where("id", auth()->id())->update($data); |
36 | - }catch (\Exception $e) { |
|
36 | + } catch (\Exception $e) { |
|
37 | 37 | Log::error($e); |
38 | - return cb()->redirectBack("Something went wrong!","warning"); |
|
38 | + return cb()->redirectBack("Something went wrong!", "warning"); |
|
39 | 39 | } |
40 | 40 | |
41 | - return cb()->redirectBack("The profile data has been updated!","success"); |
|
41 | + return cb()->redirectBack("The profile data has been updated!", "success"); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | private function assignToModel($menu) { |
23 | 23 | $model = new SidebarModel(); |
24 | 24 | $model->setId($menu->id); |
25 | - if($menu->type == "url") { |
|
25 | + if ($menu->type == "url") { |
|
26 | 26 | $model->setUrl($menu->path); |
27 | 27 | $model->setIcon($menu->icon); |
28 | 28 | $model->setName($menu->name); |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | $model->setBasepath(config('crudbooster.ADMIN_PATH').'/'.basename($model->getUrl())); |
44 | 44 | } |
45 | 45 | |
46 | - if(request()->is($model->getBasepath()."*")) { |
|
46 | + if (request()->is($model->getBasepath()."*")) { |
|
47 | 47 | $model->setIsActive(true); |
48 | - }else{ |
|
48 | + } else { |
|
49 | 49 | $model->setIsActive(false); |
50 | 50 | } |
51 | 51 | |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | |
55 | 55 | private function loadData($parent_id = null) { |
56 | 56 | $menus = DB::table("cb_menus"); |
57 | - if($parent_id) { |
|
58 | - $menus->where("parent_cb_menus_id",$parent_id); |
|
59 | - }else{ |
|
57 | + if ($parent_id) { |
|
58 | + $menus->where("parent_cb_menus_id", $parent_id); |
|
59 | + } else { |
|
60 | 60 | $menus->whereNull("parent_cb_menus_id"); |
61 | 61 | } |
62 | - return $menus->orderBy("sort_number","asc")->get(); |
|
62 | + return $menus->orderBy("sort_number", "asc")->get(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | private function rolePrivilege($cb_roles_id, $cb_menus_id) { |
66 | - return cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id]); |
|
66 | + return cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id]); |
|
67 | 67 | } |
68 | 68 | |
69 | - private function checkPrivilege($roles_id,$menu) { |
|
70 | - if($roles_id) { |
|
69 | + private function checkPrivilege($roles_id, $menu) { |
|
70 | + if ($roles_id) { |
|
71 | 71 | $privilege = $this->rolePrivilege($roles_id, $menu->id); |
72 | - if($privilege && !$privilege->can_browse) { |
|
72 | + if ($privilege && !$privilege->can_browse) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | } |
@@ -78,36 +78,36 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | public function all($withPrivilege = true) { |
81 | - $roles_id = ($withPrivilege)?cb()->session()->roleId():null; |
|
81 | + $roles_id = ($withPrivilege) ?cb()->session()->roleId() : null; |
|
82 | 82 | $menus = $this->loadData(); |
83 | 83 | $result = []; |
84 | 84 | $menus_active = false; |
85 | - foreach($menus as $menu) { |
|
85 | + foreach ($menus as $menu) { |
|
86 | 86 | |
87 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue; |
|
87 | + if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue; |
|
88 | 88 | |
89 | 89 | $sidebarModel = $this->assignToModel($menu); |
90 | - if($sidebarModel->getisActive()) $menus_active = true; |
|
91 | - if($menus2 = $this->loadData($menu->id)) { |
|
90 | + if ($sidebarModel->getisActive()) $menus_active = true; |
|
91 | + if ($menus2 = $this->loadData($menu->id)) { |
|
92 | 92 | $sub1 = []; |
93 | 93 | $menus2_active = false; |
94 | 94 | foreach ($menus2 as $menu2) { |
95 | 95 | |
96 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue; |
|
96 | + if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue; |
|
97 | 97 | |
98 | 98 | $sidebarModel2 = $this->assignToModel($menu2); |
99 | - if($sidebarModel2->getisActive()) $menus2_active = true; |
|
99 | + if ($sidebarModel2->getisActive()) $menus2_active = true; |
|
100 | 100 | |
101 | - if($menus3 = $this->loadData($menu2->id)) { |
|
101 | + if ($menus3 = $this->loadData($menu2->id)) { |
|
102 | 102 | $sub2 = []; |
103 | 103 | $menus3_active = false; |
104 | 104 | foreach ($menus3 as $menu3) { |
105 | 105 | |
106 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue; |
|
106 | + if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue; |
|
107 | 107 | |
108 | 108 | $sidebarModel3 = $this->assignToModel($menu3); |
109 | 109 | |
110 | - if($sidebarModel3->getisActive()) { |
|
110 | + if ($sidebarModel3->getisActive()) { |
|
111 | 111 | $menus3_active = true; |
112 | 112 | } |
113 | 113 |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | $this->setButtonDetail(true); |
30 | 30 | $this->setButtonSave(true); |
31 | 31 | $this->setButtonLimitPage(true); |
32 | - $this->hideButtonDeleteWhen(function ($row) { return false; }); |
|
33 | - $this->hideButtonDetailWhen(function ($row) { return false; }); |
|
34 | - $this->hideButtonEditWhen(function ($row) { return false; }); |
|
32 | + $this->hideButtonDeleteWhen(function($row) { return false; }); |
|
33 | + $this->hideButtonDetailWhen(function($row) { return false; }); |
|
34 | + $this->hideButtonEditWhen(function($row) { return false; }); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * @param ButtonColor $color |
129 | 129 | * @param string $attributes |
130 | 130 | */ |
131 | - public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null) |
|
131 | + public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null) |
|
132 | 132 | { |
133 | - $color = ($color)?:ButtonColor::DARK_BLUE; |
|
133 | + $color = ($color) ?: ButtonColor::DARK_BLUE; |
|
134 | 134 | |
135 | 135 | $model = new IndexActionButtonModel(); |
136 | 136 | $model->setLabel($label); |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | * @param $fontAwesome_icon |
186 | 186 | * @param ButtonColor|string $color |
187 | 187 | */ |
188 | - public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false) |
|
188 | + public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false) |
|
189 | 189 | { |
190 | 190 | $new = new AddActionButtonModel(); |
191 | 191 | $new->setLabel($label); |
192 | - $new->setIcon($fontAwesome_icon?:"fa fa-bars"); |
|
193 | - $new->setColor($color?:"primary"); |
|
192 | + $new->setIcon($fontAwesome_icon ?: "fa fa-bars"); |
|
193 | + $new->setColor($color ?: "primary"); |
|
194 | 194 | $new->setUrl($url_target); |
195 | 195 | $new->setCondition($condition_callback); |
196 | 196 | $new->setConfirmation($confirmation); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function detailRender($row, $column) |
29 | 29 | { |
30 | 30 | $column->setValue($row->{ $column->getField() }); |
31 | - return view("types::image.detail",[ |
|
31 | + return view("types::image.detail", [ |
|
32 | 32 | 'row'=>$row, |
33 | 33 | 'column'=>$column |
34 | 34 | ]); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function indexRender($row, $column) |
38 | 38 | { |
39 | 39 | $column->setValue($row->{ $column->getField() }); |
40 | - return view("types::image.index",[ |
|
40 | + return view("types::image.index", [ |
|
41 | 41 | 'row'=>$row, |
42 | 42 | 'column'=>$column |
43 | 43 | ]); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function detailRender($row, $column) |
28 | 28 | { |
29 | 29 | $column->setValue($row->{ $column->getField() }); |
30 | - return view("types::file.detail",[ |
|
30 | + return view("types::file.detail", [ |
|
31 | 31 | 'row'=>$row, |
32 | 32 | 'column'=>$column |
33 | 33 | ]); |
@@ -18,8 +18,8 @@ |
||
18 | 18 | */ |
19 | 19 | public function handle($request, Closure $next) |
20 | 20 | { |
21 | - if(auth()->guest()) { |
|
22 | - return cb()->redirect(cb()->getLoginUrl("login"),trans('crudbooster.not_logged_in'),'warning'); |
|
21 | + if (auth()->guest()) { |
|
22 | + return cb()->redirect(cb()->getLoginUrl("login"), trans('crudbooster.not_logged_in'), 'warning'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | (new CBHook())->beforeBackendMiddleware($request); |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | public function make() { |
43 | - $name = ($this->name)?:ucwords(str_replace("_"," ",$this->table)); |
|
43 | + $name = ($this->name) ?: ucwords(str_replace("_", " ", $this->table)); |
|
44 | 44 | |
45 | 45 | $template = file_get_contents(__DIR__."/../templates/FooBarController.stub"); |
46 | 46 | |
47 | 47 | //Replace table |
48 | - $template = str_replace("{table}",'"'.$this->table.'"', $template); |
|
48 | + $template = str_replace("{table}", '"'.$this->table.'"', $template); |
|
49 | 49 | |
50 | 50 | //Replace permalink |
51 | 51 | $template = str_replace("{permalink}", '"'.$this->table.'"', $template); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | //Replace scaffolding |
57 | 57 | $fields = DB::getSchemaBuilder()->getColumnListing($this->table); |
58 | 58 | $scaffold = ""; |
59 | - foreach($fields as $field) { |
|
59 | + foreach ($fields as $field) { |
|
60 | 60 | $scaffold .= '$this->addText("'.$field.'");'."\n\t\t"; |
61 | 61 | } |
62 | 62 | $template = str_replace("{scaffolding}", $scaffold, $template); |
@@ -9,17 +9,17 @@ discard block |
||
9 | 9 | | |
10 | 10 | */ |
11 | 11 | |
12 | -if(!function_exists('rglob')) { |
|
12 | +if (!function_exists('rglob')) { |
|
13 | 13 | function rglob($pattern, $flags = 0) { |
14 | 14 | $files = glob($pattern, $flags); |
15 | - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
|
15 | + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
|
16 | 16 | $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags)); |
17 | 17 | } |
18 | 18 | return $files; |
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | -if(!function_exists('convertPHPToMomentFormat')) { |
|
22 | +if (!function_exists('convertPHPToMomentFormat')) { |
|
23 | 23 | function convertPHPToMomentFormat($format) |
24 | 24 | { |
25 | 25 | $replacements = [ |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if(!function_exists('slug')) { |
|
69 | +if (!function_exists('slug')) { |
|
70 | 70 | function slug($string, $separator = '-') { |
71 | 71 | return \Illuminate\Support\Str::slug($string, $separator); |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -if(!function_exists('columnSingleton')) { |
|
75 | +if (!function_exists('columnSingleton')) { |
|
76 | 76 | /** |
77 | 77 | * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton |
78 | 78 | */ |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | -if(!function_exists('cbHook')) |
|
84 | +if (!function_exists('cbHook')) |
|
85 | 85 | { |
86 | 86 | /** |
87 | 87 | * @return crocodicstudio\crudbooster\hooks\CBHook |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -if(!function_exists('getTypeHook')) |
|
96 | +if (!function_exists('getTypeHook')) |
|
97 | 97 | { |
98 | 98 | /** |
99 | 99 | * @param string $type |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | -if(!function_exists('getPrimaryKey')) |
|
109 | +if (!function_exists('getPrimaryKey')) |
|
110 | 110 | { |
111 | 111 | function getPrimaryKey($table_name) |
112 | 112 | { |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | -if(!function_exists('cb')) |
|
117 | +if (!function_exists('cb')) |
|
118 | 118 | { |
119 | 119 | function cb() |
120 | 120 | { |
@@ -122,25 +122,25 @@ discard block |
||
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | -if(!function_exists('cbAsset')) { |
|
125 | +if (!function_exists('cbAsset')) { |
|
126 | 126 | function cbAsset($path) { |
127 | 127 | return asset("cb_asset/".$path); |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | -if(!function_exists("cbConfig")) { |
|
131 | +if (!function_exists("cbConfig")) { |
|
132 | 132 | function cbConfig($name) { |
133 | 133 | return config("crudbooster.".$name); |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | -if(!function_exists("strRandom")) { |
|
137 | +if (!function_exists("strRandom")) { |
|
138 | 138 | function strRandom($length = 5) { |
139 | 139 | return \Illuminate\Support\Str::random($length); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | -if(!function_exists('module')) { |
|
143 | +if (!function_exists('module')) { |
|
144 | 144 | function module() |
145 | 145 | { |
146 | 146 | $module = new \crocodicstudio\crudbooster\helpers\Module(); |
@@ -148,43 +148,43 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | -if(!function_exists('getAdminLoginURL')) { |
|
151 | +if (!function_exists('getAdminLoginURL')) { |
|
152 | 152 | function getAdminLoginURL() |
153 | 153 | { |
154 | 154 | return url(config('crudbooster.ADMIN_LOGIN_PATH')); |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | -if(!function_exists('dummyPhoto')) { |
|
158 | +if (!function_exists('dummyPhoto')) { |
|
159 | 159 | function dummyPhoto() |
160 | 160 | { |
161 | 161 | return config('crudbooster.DUMMY_PHOTO'); |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | -if(!function_exists('assetThumbnail')) { |
|
165 | +if (!function_exists('assetThumbnail')) { |
|
166 | 166 | function assetThumbnail($path) { |
167 | - $path = str_replace('uploads/','uploads_thumbnail/',$path); |
|
167 | + $path = str_replace('uploads/', 'uploads_thumbnail/', $path); |
|
168 | 168 | return asset($path); |
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | -if(!function_exists('assetResize')) { |
|
173 | - function assetResize($path,$width,$height=null,$quality=70) { |
|
172 | +if (!function_exists('assetResize')) { |
|
173 | + function assetResize($path, $width, $height = null, $quality = 70) { |
|
174 | 174 | $basename = basename($path); |
175 | 175 | $pathWithoutName = str_replace($basename, '', $path); |
176 | 176 | $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
177 | - if(Storage::exists($newLocation)) { |
|
177 | + if (Storage::exists($newLocation)) { |
|
178 | 178 | return asset($newLocation); |
179 | - }else{ |
|
180 | - $img = Image::make(storage_path($path))->fit($width,$height); |
|
181 | - $img->save(storage_path($newLocation),$quality); |
|
179 | + } else { |
|
180 | + $img = Image::make(storage_path($path))->fit($width, $height); |
|
181 | + $img->save(storage_path($newLocation), $quality); |
|
182 | 182 | return asset($newLocation); |
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | -if(!function_exists('extract_unit')) { |
|
187 | +if (!function_exists('extract_unit')) { |
|
188 | 188 | /* |
189 | 189 | Credits: Bit Repository |
190 | 190 | URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | |
205 | -if(!function_exists('now')) { |
|
205 | +if (!function_exists('now')) { |
|
206 | 206 | function now() { |
207 | 207 | return date('Y-m-d H:i:s'); |
208 | 208 | } |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | | |
217 | 217 | */ |
218 | 218 | |
219 | -if(!function_exists('putSetting')) { |
|
219 | +if (!function_exists('putSetting')) { |
|
220 | 220 | function putSetting($key, $value) |
221 | 221 | { |
222 | - if(file_exists(storage_path('.cbconfig'))) { |
|
222 | + if (file_exists(storage_path('.cbconfig'))) { |
|
223 | 223 | $settings = file_get_contents(storage_path('.cbconfig')); |
224 | 224 | $settings = unserialize($settings); |
225 | - }else{ |
|
225 | + } else { |
|
226 | 226 | $settings = []; |
227 | 227 | } |
228 | 228 | |
@@ -233,25 +233,25 @@ discard block |
||
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | -if(!function_exists('getSetting')) { |
|
236 | +if (!function_exists('getSetting')) { |
|
237 | 237 | function getSetting($key, $default = null) |
238 | 238 | { |
239 | - if(file_exists(storage_path('.cbconfig'))) { |
|
239 | + if (file_exists(storage_path('.cbconfig'))) { |
|
240 | 240 | $settings = file_get_contents(storage_path('.cbconfig')); |
241 | 241 | $settings = unserialize($settings); |
242 | - }else{ |
|
242 | + } else { |
|
243 | 243 | $settings = []; |
244 | 244 | } |
245 | 245 | |
246 | - if(isset($settings[$key])) { |
|
247 | - return $settings[$key]?:$default; |
|
248 | - }else{ |
|
246 | + if (isset($settings[$key])) { |
|
247 | + return $settings[$key] ?: $default; |
|
248 | + } else { |
|
249 | 249 | return $default; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | -if(!function_exists('timeAgo')) { |
|
254 | +if (!function_exists('timeAgo')) { |
|
255 | 255 | function timeAgo($datetime_to, $datetime_from = null, $full = false) |
256 | 256 | { |
257 | 257 | $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s'); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | - if (! $full) { |
|
285 | + if (!$full) { |
|
286 | 286 | $string = array_slice($string, 0, 1); |
287 | 287 | } |
288 | 288 | |
@@ -290,22 +290,22 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | -if(!function_exists("array_map_r")) { |
|
294 | - function array_map_r( $func, $arr ) |
|
293 | +if (!function_exists("array_map_r")) { |
|
294 | + function array_map_r($func, $arr) |
|
295 | 295 | { |
296 | 296 | $newArr = array(); |
297 | 297 | |
298 | - foreach( $arr as $key => $value ) |
|
298 | + foreach ($arr as $key => $value) |
|
299 | 299 | { |
300 | 300 | $key = $func($key); |
301 | - $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) ); |
|
301 | + $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value))); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | return $newArr; |
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | -if(!function_exists("sanitizeXSS")) |
|
308 | +if (!function_exists("sanitizeXSS")) |
|
309 | 309 | { |
310 | 310 | function sanitizeXSS($value) |
311 | 311 | { |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | -if(!function_exists("requestAll")) { |
|
320 | +if (!function_exists("requestAll")) { |
|
321 | 321 | function requestAll() { |
322 | 322 | $all = array_map_r("sanitizeXSS", request()->all()); |
323 | 323 | return $all; |
@@ -326,22 +326,22 @@ discard block |
||
326 | 326 | |
327 | 327 | |
328 | 328 | |
329 | -if(!function_exists('getURLFormat')) { |
|
329 | +if (!function_exists('getURLFormat')) { |
|
330 | 330 | function getURLFormat($name) { |
331 | 331 | $url = request($name); |
332 | - if(filter_var($url, FILTER_VALIDATE_URL)) { |
|
332 | + if (filter_var($url, FILTER_VALIDATE_URL)) { |
|
333 | 333 | return $url; |
334 | - }else{ |
|
334 | + } else { |
|
335 | 335 | return request()->url(); |
336 | 336 | } |
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | -if(!function_exists('g')) { |
|
340 | +if (!function_exists('g')) { |
|
341 | 341 | function g($name, $safe = true) { |
342 | - if($safe == true) { |
|
342 | + if ($safe == true) { |
|
343 | 343 | $response = request($name); |
344 | - if(is_string($response)) { |
|
344 | + if (is_string($response)) { |
|
345 | 345 | $response = sanitizeXSS($response); |
346 | 346 | }elseif (is_array($response)) { |
347 | 347 | array_walk_recursive($response, function(&$response) { |
@@ -350,25 +350,25 @@ discard block |
||
350 | 350 | } |
351 | 351 | |
352 | 352 | return $response; |
353 | - }else{ |
|
353 | + } else { |
|
354 | 354 | return Request::get($name); |
355 | 355 | } |
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | -if(!function_exists('min_var_export')) { |
|
359 | +if (!function_exists('min_var_export')) { |
|
360 | 360 | function min_var_export($input) { |
361 | - if(is_array($input)) { |
|
361 | + if (is_array($input)) { |
|
362 | 362 | $buffer = []; |
363 | - foreach($input as $key => $value) |
|
363 | + foreach ($input as $key => $value) |
|
364 | 364 | $buffer[] = var_export($key, true)."=>".min_var_export($value); |
365 | - return "[".implode(",",$buffer)."]"; |
|
365 | + return "[".implode(",", $buffer)."]"; |
|
366 | 366 | } else |
367 | 367 | return var_export($input, true); |
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | -if(!function_exists('rrmdir')) { |
|
371 | +if (!function_exists('rrmdir')) { |
|
372 | 372 | /* |
373 | 373 | * http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir |
374 | 374 | */ |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __call($method, $parameters) |
28 | 28 | { |
29 | - if($method == "getData") { |
|
29 | + if ($method == "getData") { |
|
30 | 30 | $key = $parameters[0]; |
31 | - if(isset($this->data[$key])) { |
|
31 | + if (isset($this->data[$key])) { |
|
32 | 32 | return $this->data[$key]; |
33 | - }else{ |
|
33 | + } else { |
|
34 | 34 | return null; |
35 | 35 | } |
36 | - }else{ |
|
36 | + } else { |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | } |
@@ -48,19 +48,19 @@ discard block |
||
48 | 48 | |
49 | 49 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
50 | 50 | |
51 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
51 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
52 | 52 | { |
53 | 53 | $query = call_user_func($this->data['hook_query_index'], $query); |
54 | 54 | } |
55 | 55 | |
56 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
57 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
56 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
57 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
58 | 58 | $query->whereNull($this->data['table'].'.deleted_at'); |
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | - if(isset($joins)) { |
|
63 | - foreach($joins as $join) |
|
62 | + if (isset($joins)) { |
|
63 | + foreach ($joins as $join) |
|
64 | 64 | { |
65 | 65 | $query->join($join['target_table'], |
66 | 66 | $join['target_table_primary'], |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - foreach($columns as $column) { |
|
73 | + foreach ($columns as $column) { |
|
74 | 74 | /** @var ColumnModel $column */ |
75 | - if(strpos($column->getField(),".") === false) { |
|
75 | + if (strpos($column->getField(), ".") === false) { |
|
76 | 76 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
77 | - }else{ |
|
77 | + } else { |
|
78 | 78 | $query->addSelect($column->getField()); |
79 | 79 | } |
80 | 80 | |
81 | 81 | $query = getTypeHook($column->getType())->query($query, $column); |
82 | 82 | } |
83 | 83 | |
84 | - if(request()->has('q')) |
|
84 | + if (request()->has('q')) |
|
85 | 85 | { |
86 | - if(isset($this->data['hook_search_query'])) { |
|
86 | + if (isset($this->data['hook_search_query'])) { |
|
87 | 87 | $query = call_user_func($this->data['hook_search_query'], $query); |
88 | - }else{ |
|
89 | - $query->where(function ($where) use ($columns) { |
|
88 | + } else { |
|
89 | + $query->where(function($where) use ($columns) { |
|
90 | 90 | /** |
91 | 91 | * @var $where Builder |
92 | 92 | */ |
93 | - foreach($columns as $column) |
|
93 | + foreach ($columns as $column) |
|
94 | 94 | { |
95 | - if(strpos($column->getField(),".") === false) { |
|
95 | + if (strpos($column->getField(), ".") === false) { |
|
96 | 96 | $field = $this->data['table'].'.'.$column->getField(); |
97 | - }else{ |
|
97 | + } else { |
|
98 | 98 | $field = $column->getField(); |
99 | 99 | } |
100 | 100 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
106 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
107 | 107 | $query = call_user_func($this->data['hook_query_index'], $query); |
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | - if(request()->has(['order_by','order_sort'])) |
|
111 | + if (request()->has(['order_by', 'order_sort'])) |
|
112 | 112 | { |
113 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
113 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
114 | 114 | $query->orderBy(request('order_by'), request('order_sort')); |
115 | 115 | } |
116 | - }else{ |
|
116 | + } else { |
|
117 | 117 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
118 | 118 | } |
119 | 119 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | public function getIndex() |
124 | 124 | { |
125 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
125 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
126 | 126 | |
127 | 127 | $query = $this->repository(); |
128 | 128 | $result = $query->paginate(20); |
@@ -137,29 +137,29 @@ discard block |
||
137 | 137 | */ |
138 | 138 | private function validation() |
139 | 139 | { |
140 | - if(isset($this->data['validation'])) { |
|
140 | + if (isset($this->data['validation'])) { |
|
141 | 141 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
142 | 142 | if ($validator->fails()) { |
143 | 143 | $message = $validator->messages(); |
144 | 144 | $message_all = $message->all(); |
145 | - throw new CBValidationException(implode(', ',$message_all)); |
|
145 | + throw new CBValidationException(implode(', ', $message_all)); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | public function getAdd() |
151 | 151 | { |
152 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
152 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
153 | 153 | |
154 | 154 | $data = []; |
155 | 155 | $data['page_title'] = $this->data['page_title'].' : Add'; |
156 | 156 | $data['action_url'] = module()->addSaveURL(); |
157 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
157 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function postAddSave() |
161 | 161 | { |
162 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
162 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
163 | 163 | |
164 | 164 | try { |
165 | 165 | $this->validation(); |
@@ -167,24 +167,24 @@ discard block |
||
167 | 167 | $data = columnSingleton()->getAssignmentData(); |
168 | 168 | |
169 | 169 | //Clear data from Primary Key |
170 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
170 | + unset($data[cb()->pk($this->data['table'])]); |
|
171 | 171 | |
172 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
172 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
173 | 173 | $data['created_at'] = date('Y-m-d H:i:s'); |
174 | 174 | } |
175 | 175 | |
176 | 176 | $id = DB::table($this->data['table'])->insertGetId($data); |
177 | 177 | |
178 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
178 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
179 | 179 | call_user_func($this->data['hook_after_insert'], $id); |
180 | 180 | } |
181 | 181 | |
182 | 182 | } catch (CBValidationException $e) { |
183 | 183 | Log::debug($e); |
184 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
184 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
185 | 185 | } catch (\Exception $e) { |
186 | 186 | Log::error($e); |
187 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
187 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | if (request('submit') == trans('crudbooster.button_save_more')) { |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | public function getEdit($id) |
198 | 198 | { |
199 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
199 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
200 | 200 | |
201 | 201 | $data = []; |
202 | 202 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | public function postEditSave($id) |
209 | 209 | { |
210 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
210 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
211 | 211 | |
212 | 212 | try { |
213 | 213 | $this->validation(); |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | $data = columnSingleton()->getAssignmentData(); |
216 | 216 | |
217 | 217 | //Clear data from Primary Key |
218 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
218 | + unset($data[cb()->pk($this->data['table'])]); |
|
219 | 219 | |
220 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
220 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
221 | 221 | $data['updated_at'] = date('Y-m-d H:i:s'); |
222 | 222 | } |
223 | 223 | |
224 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
224 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
225 | 225 | call_user_func($this->data['hook_before_update'], $id); |
226 | 226 | } |
227 | 227 | |
@@ -229,16 +229,16 @@ discard block |
||
229 | 229 | ->where(cb()->pk($this->data['table']), $id) |
230 | 230 | ->update($data); |
231 | 231 | |
232 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
232 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
233 | 233 | call_user_func($this->data['hook_after_update'], $id); |
234 | 234 | } |
235 | 235 | |
236 | 236 | } catch (CBValidationException $e) { |
237 | 237 | Log::debug($e); |
238 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
238 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
239 | 239 | } catch (\Exception $e) { |
240 | 240 | Log::error($e); |
241 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
241 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -251,15 +251,15 @@ discard block |
||
251 | 251 | |
252 | 252 | public function getDelete($id) |
253 | 253 | { |
254 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
254 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
255 | 255 | |
256 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
256 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
257 | 257 | call_user_func($this->data['hook_before_delete'], $id); |
258 | 258 | } |
259 | 259 | |
260 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
260 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
261 | 261 | |
262 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
262 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
263 | 263 | DB::table($this->data['table']) |
264 | 264 | ->where(getPrimaryKey($this->data['table']), $id) |
265 | 265 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | ->delete(); |
270 | 270 | } |
271 | 271 | |
272 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
272 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
273 | 273 | call_user_func($this->data['hook_after_delete'], $id); |
274 | 274 | } |
275 | 275 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | public function getDetail($id) |
280 | 280 | { |
281 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
281 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
282 | 282 | |
283 | 283 | $data = []; |
284 | 284 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |