@@ -30,9 +30,9 @@ |
||
30 | 30 | /* |
31 | 31 | * For security reason we have limit the upload file formats bellow |
32 | 32 | */ |
33 | - 'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif','pdf','xls','xlsx','doc','docx','txt','zip','rar','rtf'], |
|
33 | + 'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'xls', 'xlsx', 'doc', 'docx', 'txt', 'zip', 'rar', 'rtf'], |
|
34 | 34 | |
35 | - 'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif'], |
|
35 | + 'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif'], |
|
36 | 36 | |
37 | 37 | /* |
38 | 38 | * Google FCM Server Key is used to send a notification via FireBase cloud message |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $fullStoragePath = storage_path('app/'.$fullFilePath); |
35 | 35 | $lifetime = 31556926; // One year in seconds |
36 | 36 | |
37 | - if (! Storage::exists($fullFilePath)) { |
|
37 | + if (!Storage::exists($fullFilePath)) { |
|
38 | 38 | abort(404); |
39 | 39 | } |
40 | 40 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | $h = Request::get('h') ?: $w; |
56 | 56 | } |
57 | 57 | |
58 | - $imgRaw = Image::cache(function ($image) use ($fullStoragePath, $w, $h) { |
|
58 | + $imgRaw = Image::cache(function($image) use ($fullStoragePath, $w, $h) { |
|
59 | 59 | $im = $image->make($fullStoragePath); |
60 | 60 | if ($w) { |
61 | - if (! $h) { |
|
61 | + if (!$h) { |
|
62 | 62 | $im->fit($w); |
63 | 63 | } else { |
64 | 64 | $im->fit($w, $h); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | private function existsPrivilege($cb_roles_id, $cb_menus_id) { |
81 | 81 | if($row = cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id])) { |
82 | 82 | return $row->id; |
83 | - }else{ |
|
83 | + } else{ |
|
84 | 84 | return null; |
85 | 85 | } |
86 | 86 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $privilege["can_delete"] = $menu['can_delete']?:0; |
103 | 103 | if($privilege_id = $this->existsPrivilege($id, $menus_id)) { |
104 | 104 | DB::table("cb_role_privileges")->where("id", $privilege_id)->update($privilege); |
105 | - }else{ |
|
105 | + } else{ |
|
106 | 106 | DB::table("cb_role_privileges")->insert($privilege); |
107 | 107 | } |
108 | 108 | } |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | public function getIndex() { |
26 | 26 | $data = []; |
27 | 27 | $data['result'] = DB::table("cb_roles")->get(); |
28 | - return view($this->view.".index",$data); |
|
28 | + return view($this->view.".index", $data); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function getAdd() { |
32 | 32 | $data = []; |
33 | - $data['menus'] = DB::table("cb_menus")->orderBy("name","asc")->get(); |
|
33 | + $data['menus'] = DB::table("cb_menus")->orderBy("name", "asc")->get(); |
|
34 | 34 | return view($this->view.".add", $data); |
35 | 35 | } |
36 | 36 | |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | $privilege = []; |
49 | 49 | $privilege["cb_roles_id"] = $roles_id; |
50 | 50 | $privilege["cb_menus_id"] = $menus_id; |
51 | - $privilege["can_browse"] = $menu['can_browse']?:0; |
|
52 | - $privilege["can_create"] = $menu['can_create']?:0; |
|
53 | - $privilege["can_read"] = $menu['can_read']?:0; |
|
54 | - $privilege["can_update"] = $menu['can_update']?:0; |
|
55 | - $privilege["can_delete"] = $menu['can_delete']?:0; |
|
51 | + $privilege["can_browse"] = $menu['can_browse'] ?: 0; |
|
52 | + $privilege["can_create"] = $menu['can_create'] ?: 0; |
|
53 | + $privilege["can_read"] = $menu['can_read'] ?: 0; |
|
54 | + $privilege["can_update"] = $menu['can_update'] ?: 0; |
|
55 | + $privilege["can_delete"] = $menu['can_delete'] ?: 0; |
|
56 | 56 | DB::table("cb_role_privileges")->insert($privilege); |
57 | 57 | } |
58 | 58 | |
59 | 59 | DB::commit(); |
60 | 60 | |
61 | - return cb()->redirect(route("DeveloperRolesControllerGetIndex"),"The role has been saved!","success"); |
|
61 | + return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been saved!", "success"); |
|
62 | 62 | |
63 | 63 | } catch (CBValidationException $e) { |
64 | 64 | return cb()->redirectBack($e->getMessage()); |
@@ -73,21 +73,21 @@ discard block |
||
73 | 73 | $data['row'] = cb()->find("cb_roles", $id); |
74 | 74 | |
75 | 75 | $menus = DB::table("cb_menus") |
76 | - ->leftjoin("cb_role_privileges",function($join) use ($id) { |
|
77 | - $join->on("cb_role_privileges.cb_menus_id","=","cb_menus.id")->where("cb_role_privileges.cb_roles_id", $id); |
|
76 | + ->leftjoin("cb_role_privileges", function($join) use ($id) { |
|
77 | + $join->on("cb_role_privileges.cb_menus_id", "=", "cb_menus.id")->where("cb_role_privileges.cb_roles_id", $id); |
|
78 | 78 | }) |
79 | - ->orderBy("cb_menus.name","asc") |
|
80 | - ->select("cb_menus.*","can_browse","can_create","can_read","can_update","can_delete") |
|
79 | + ->orderBy("cb_menus.name", "asc") |
|
80 | + ->select("cb_menus.*", "can_browse", "can_create", "can_read", "can_update", "can_delete") |
|
81 | 81 | ->get(); |
82 | 82 | $data['menus'] = $menus; |
83 | 83 | |
84 | - return view($this->view.".edit",$data); |
|
84 | + return view($this->view.".edit", $data); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | private function existsPrivilege($cb_roles_id, $cb_menus_id) { |
88 | - if($row = cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id])) { |
|
88 | + if ($row = cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id])) { |
|
89 | 89 | return $row->id; |
90 | - }else{ |
|
90 | + } else { |
|
91 | 91 | return null; |
92 | 92 | } |
93 | 93 | } |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | try { |
97 | 97 | cb()->validation(['name', 'menus']); |
98 | 98 | |
99 | - cb()->updateCompact("cb_roles",$id,['name']); |
|
99 | + cb()->updateCompact("cb_roles", $id, ['name']); |
|
100 | 100 | |
101 | 101 | foreach (request("menus") as $menus_id => $menu) { |
102 | 102 | $privilege = []; |
103 | 103 | $privilege["cb_roles_id"] = $id; |
104 | 104 | $privilege["cb_menus_id"] = $menus_id; |
105 | - $privilege["can_browse"] = $menu['can_browse']?:0; |
|
106 | - $privilege["can_create"] = $menu['can_create']?:0; |
|
107 | - $privilege["can_read"] = $menu['can_read']?:0; |
|
108 | - $privilege["can_update"] = $menu['can_update']?:0; |
|
109 | - $privilege["can_delete"] = $menu['can_delete']?:0; |
|
110 | - if($privilege_id = $this->existsPrivilege($id, $menus_id)) { |
|
105 | + $privilege["can_browse"] = $menu['can_browse'] ?: 0; |
|
106 | + $privilege["can_create"] = $menu['can_create'] ?: 0; |
|
107 | + $privilege["can_read"] = $menu['can_read'] ?: 0; |
|
108 | + $privilege["can_update"] = $menu['can_update'] ?: 0; |
|
109 | + $privilege["can_delete"] = $menu['can_delete'] ?: 0; |
|
110 | + if ($privilege_id = $this->existsPrivilege($id, $menus_id)) { |
|
111 | 111 | DB::table("cb_role_privileges")->where("id", $privilege_id)->update($privilege); |
112 | - }else{ |
|
112 | + } else { |
|
113 | 113 | DB::table("cb_role_privileges")->insert($privilege); |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - return cb()->redirect(route("DeveloperRolesControllerGetIndex"),"The role has been saved!","success"); |
|
117 | + return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been saved!", "success"); |
|
118 | 118 | |
119 | 119 | } catch (CBValidationException $e) { |
120 | 120 | |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | |
125 | 125 | public function getDelete($id) { |
126 | 126 | DB::table("cb_roles")->where("id", $id)->delete(); |
127 | - DB::table("cb_role_privileges")->where("cb_roles_id",$id)->delete(); |
|
127 | + DB::table("cb_role_privileges")->where("cb_roles_id", $id)->delete(); |
|
128 | 128 | |
129 | - return cb()->redirectBack("The role has been deleted!","success"); |
|
129 | + return cb()->redirectBack("The role has been deleted!", "success"); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | } |
133 | 133 | \ No newline at end of file |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $data['photo'] = cb()->uploadFile('photo', true, 200, 200); |
32 | 32 | } |
33 | 33 | DB::table("users")->where("id", auth()->id())->update($data); |
34 | - }catch (\Exception $e) { |
|
34 | + } catch (\Exception $e) { |
|
35 | 35 | Log::error($e); |
36 | 36 | return cb()->redirectBack("Something went wrong!","warning"); |
37 | 37 | } |
@@ -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 | } |
@@ -118,49 +118,49 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | if(!function_exists('assetThumbnail')) { |
121 | - function assetThumbnail($path) { |
|
122 | - $path = str_replace('uploads/','uploads_thumbnail/',$path); |
|
123 | - return asset($path); |
|
124 | - } |
|
121 | + function assetThumbnail($path) { |
|
122 | + $path = str_replace('uploads/','uploads_thumbnail/',$path); |
|
123 | + return asset($path); |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | if(!function_exists('assetResize')) { |
128 | - function assetResize($path,$width,$height=null,$quality=70) { |
|
129 | - $basename = basename($path); |
|
130 | - $pathWithoutName = str_replace($basename, '', $path); |
|
131 | - $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
|
132 | - if(Storage::exists($newLocation)) { |
|
133 | - return asset($newLocation); |
|
134 | - }else{ |
|
135 | - $img = Image::make(storage_path($path))->fit($width,$height); |
|
136 | - $img->save(storage_path($newLocation),$quality); |
|
137 | - return asset($newLocation); |
|
138 | - } |
|
139 | - } |
|
128 | + function assetResize($path,$width,$height=null,$quality=70) { |
|
129 | + $basename = basename($path); |
|
130 | + $pathWithoutName = str_replace($basename, '', $path); |
|
131 | + $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
|
132 | + if(Storage::exists($newLocation)) { |
|
133 | + return asset($newLocation); |
|
134 | + }else{ |
|
135 | + $img = Image::make(storage_path($path))->fit($width,$height); |
|
136 | + $img->save(storage_path($newLocation),$quality); |
|
137 | + return asset($newLocation); |
|
138 | + } |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if(!function_exists('extract_unit')) { |
143 | - /* |
|
143 | + /* |
|
144 | 144 | Credits: Bit Repository |
145 | 145 | URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html |
146 | 146 | */ |
147 | - function extract_unit($string, $start, $end) |
|
148 | - { |
|
149 | - $pos = stripos($string, $start); |
|
150 | - $str = substr($string, $pos); |
|
151 | - $str_two = substr($str, strlen($start)); |
|
152 | - $second_pos = stripos($str_two, $end); |
|
153 | - $str_three = substr($str_two, 0, $second_pos); |
|
154 | - $unit = trim($str_three); // remove whitespaces |
|
155 | - return $unit; |
|
156 | - } |
|
147 | + function extract_unit($string, $start, $end) |
|
148 | + { |
|
149 | + $pos = stripos($string, $start); |
|
150 | + $str = substr($string, $pos); |
|
151 | + $str_two = substr($str, strlen($start)); |
|
152 | + $second_pos = stripos($str_two, $end); |
|
153 | + $str_three = substr($str_two, 0, $second_pos); |
|
154 | + $unit = trim($str_three); // remove whitespaces |
|
155 | + return $unit; |
|
156 | + } |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
160 | 160 | if(!function_exists('now')) { |
161 | - function now() { |
|
162 | - return date('Y-m-d H:i:s'); |
|
163 | - } |
|
161 | + function now() { |
|
162 | + return date('Y-m-d H:i:s'); |
|
163 | + } |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /* |
@@ -324,22 +324,22 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | if(!function_exists('rrmdir')) { |
327 | - /* |
|
327 | + /* |
|
328 | 328 | * http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir |
329 | 329 | */ |
330 | - function rrmdir($dir) { |
|
331 | - if (is_dir($dir)) { |
|
332 | - $objects = scandir($dir); |
|
333 | - foreach ($objects as $object) { |
|
334 | - if ($object != "." && $object != "..") { |
|
335 | - if (is_dir($dir."/".$object)) |
|
336 | - rrmdir($dir."/".$object); |
|
337 | - else |
|
338 | - unlink($dir."/".$object); |
|
339 | - } |
|
340 | - } |
|
341 | - rmdir($dir); |
|
342 | - } |
|
343 | - } |
|
330 | + function rrmdir($dir) { |
|
331 | + if (is_dir($dir)) { |
|
332 | + $objects = scandir($dir); |
|
333 | + foreach ($objects as $object) { |
|
334 | + if ($object != "." && $object != "..") { |
|
335 | + if (is_dir($dir."/".$object)) |
|
336 | + rrmdir($dir."/".$object); |
|
337 | + else |
|
338 | + unlink($dir."/".$object); |
|
339 | + } |
|
340 | + } |
|
341 | + rmdir($dir); |
|
342 | + } |
|
343 | + } |
|
344 | 344 | } |
345 | 345 |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
132 | 132 | if(Storage::exists($newLocation)) { |
133 | 133 | return asset($newLocation); |
134 | - }else{ |
|
134 | + } else{ |
|
135 | 135 | $img = Image::make(storage_path($path))->fit($width,$height); |
136 | 136 | $img->save(storage_path($newLocation),$quality); |
137 | 137 | return asset($newLocation); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | if(file_exists(storage_path('.cbconfig'))) { |
178 | 178 | $settings = file_get_contents(storage_path('.cbconfig')); |
179 | 179 | $settings = unserialize($settings); |
180 | - }else{ |
|
180 | + } else{ |
|
181 | 181 | $settings = []; |
182 | 182 | } |
183 | 183 | |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | if(file_exists(storage_path('.cbconfig'))) { |
195 | 195 | $settings = file_get_contents(storage_path('.cbconfig')); |
196 | 196 | $settings = unserialize($settings); |
197 | - }else{ |
|
197 | + } else{ |
|
198 | 198 | $settings = []; |
199 | 199 | } |
200 | 200 | |
201 | 201 | if(isset($settings[$key])) { |
202 | 202 | return $settings[$key]?:$default; |
203 | - }else{ |
|
203 | + } else{ |
|
204 | 204 | return $default; |
205 | 205 | } |
206 | 206 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $url = request($name); |
287 | 287 | if(filter_var($url, FILTER_VALIDATE_URL)) { |
288 | 288 | return $url; |
289 | - }else{ |
|
289 | + } else{ |
|
290 | 290 | return request()->url(); |
291 | 291 | } |
292 | 292 | } |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | $response = request($name); |
299 | 299 | if(is_string($response)) { |
300 | 300 | $response = sanitizeXSS($response); |
301 | - }elseif (is_array($response)) { |
|
301 | + } elseif (is_array($response)) { |
|
302 | 302 | array_walk_recursive($response, function(&$response) { |
303 | 303 | $response = sanitizeXSS($response); |
304 | 304 | }); |
305 | 305 | } |
306 | 306 | |
307 | 307 | return $response; |
308 | - }else{ |
|
308 | + } else{ |
|
309 | 309 | return Request::get($name); |
310 | 310 | } |
311 | 311 | } |
@@ -315,11 +315,13 @@ discard block |
||
315 | 315 | function min_var_export($input) { |
316 | 316 | if(is_array($input)) { |
317 | 317 | $buffer = []; |
318 | - foreach($input as $key => $value) |
|
319 | - $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
318 | + foreach($input as $key => $value) { |
|
319 | + $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
320 | + } |
|
320 | 321 | return "[".implode(",",$buffer)."]"; |
321 | - } else |
|
322 | - return var_export($input, true); |
|
322 | + } else { |
|
323 | + return var_export($input, true); |
|
324 | + } |
|
323 | 325 | } |
324 | 326 | } |
325 | 327 | |
@@ -332,10 +334,11 @@ discard block |
||
332 | 334 | $objects = scandir($dir); |
333 | 335 | foreach ($objects as $object) { |
334 | 336 | if ($object != "." && $object != "..") { |
335 | - if (is_dir($dir."/".$object)) |
|
336 | - rrmdir($dir."/".$object); |
|
337 | - else |
|
338 | - unlink($dir."/".$object); |
|
337 | + if (is_dir($dir."/".$object)) { |
|
338 | + rrmdir($dir."/".$object); |
|
339 | + } else { |
|
340 | + unlink($dir."/".$object); |
|
341 | + } |
|
339 | 342 | } |
340 | 343 | } |
341 | 344 | rmdir($dir); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | | |
10 | 10 | */ |
11 | 11 | |
12 | -if(!function_exists('convertPHPToMomentFormat')) { |
|
12 | +if (!function_exists('convertPHPToMomentFormat')) { |
|
13 | 13 | function convertPHPToMomentFormat($format) |
14 | 14 | { |
15 | 15 | $replacements = [ |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | -if(!function_exists('slug')) { |
|
59 | +if (!function_exists('slug')) { |
|
60 | 60 | function slug($string, $separator = '-') { |
61 | 61 | return \Illuminate\Support\Str::slug($string, $separator); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | -if(!function_exists('columnSingleton')) { |
|
65 | +if (!function_exists('columnSingleton')) { |
|
66 | 66 | /** |
67 | 67 | * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton |
68 | 68 | */ |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | -if(!function_exists('cbHook')) |
|
74 | +if (!function_exists('cbHook')) |
|
75 | 75 | { |
76 | 76 | /** |
77 | 77 | * @return crocodicstudio\crudbooster\hooks\CBHook |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | -if(!function_exists('getTypeHook')) |
|
86 | +if (!function_exists('getTypeHook')) |
|
87 | 87 | { |
88 | 88 | /** |
89 | 89 | * @param string $type |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | -if(!function_exists('getPrimaryKey')) |
|
99 | +if (!function_exists('getPrimaryKey')) |
|
100 | 100 | { |
101 | 101 | function getPrimaryKey($table_name) |
102 | 102 | { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if(!function_exists('cb')) |
|
107 | +if (!function_exists('cb')) |
|
108 | 108 | { |
109 | 109 | function cb() |
110 | 110 | { |
@@ -112,25 +112,25 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | -if(!function_exists('cbAsset')) { |
|
115 | +if (!function_exists('cbAsset')) { |
|
116 | 116 | function cbAsset($path) { |
117 | 117 | return asset("cb_asset/".$path); |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | -if(!function_exists("cbConfig")) { |
|
121 | +if (!function_exists("cbConfig")) { |
|
122 | 122 | function cbConfig($name) { |
123 | 123 | return config("crudbooster.".$name); |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | -if(!function_exists("strRandom")) { |
|
127 | +if (!function_exists("strRandom")) { |
|
128 | 128 | function strRandom($length = 5) { |
129 | 129 | return \Illuminate\Support\Str::random($length); |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | -if(!function_exists('module')) { |
|
133 | +if (!function_exists('module')) { |
|
134 | 134 | function module() |
135 | 135 | { |
136 | 136 | $module = new \crocodicstudio\crudbooster\helpers\Module(); |
@@ -138,43 +138,43 @@ discard block |
||
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | -if(!function_exists('getAdminLoginURL')) { |
|
141 | +if (!function_exists('getAdminLoginURL')) { |
|
142 | 142 | function getAdminLoginURL() |
143 | 143 | { |
144 | 144 | return url(config('crudbooster.ADMIN_LOGIN_PATH')); |
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | -if(!function_exists('dummyPhoto')) { |
|
148 | +if (!function_exists('dummyPhoto')) { |
|
149 | 149 | function dummyPhoto() |
150 | 150 | { |
151 | 151 | return config('crudbooster.DUMMY_PHOTO'); |
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | -if(!function_exists('assetThumbnail')) { |
|
155 | +if (!function_exists('assetThumbnail')) { |
|
156 | 156 | function assetThumbnail($path) { |
157 | - $path = str_replace('uploads/','uploads_thumbnail/',$path); |
|
157 | + $path = str_replace('uploads/', 'uploads_thumbnail/', $path); |
|
158 | 158 | return asset($path); |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | -if(!function_exists('assetResize')) { |
|
163 | - function assetResize($path,$width,$height=null,$quality=70) { |
|
162 | +if (!function_exists('assetResize')) { |
|
163 | + function assetResize($path, $width, $height = null, $quality = 70) { |
|
164 | 164 | $basename = basename($path); |
165 | 165 | $pathWithoutName = str_replace($basename, '', $path); |
166 | 166 | $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
167 | - if(Storage::exists($newLocation)) { |
|
167 | + if (Storage::exists($newLocation)) { |
|
168 | 168 | return asset($newLocation); |
169 | - }else{ |
|
170 | - $img = Image::make(storage_path($path))->fit($width,$height); |
|
171 | - $img->save(storage_path($newLocation),$quality); |
|
169 | + } else { |
|
170 | + $img = Image::make(storage_path($path))->fit($width, $height); |
|
171 | + $img->save(storage_path($newLocation), $quality); |
|
172 | 172 | return asset($newLocation); |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | -if(!function_exists('extract_unit')) { |
|
177 | +if (!function_exists('extract_unit')) { |
|
178 | 178 | /* |
179 | 179 | Credits: Bit Repository |
180 | 180 | URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | |
195 | -if(!function_exists('now')) { |
|
195 | +if (!function_exists('now')) { |
|
196 | 196 | function now() { |
197 | 197 | return date('Y-m-d H:i:s'); |
198 | 198 | } |
@@ -206,13 +206,13 @@ discard block |
||
206 | 206 | | |
207 | 207 | */ |
208 | 208 | |
209 | -if(!function_exists('putSetting')) { |
|
209 | +if (!function_exists('putSetting')) { |
|
210 | 210 | function putSetting($key, $value) |
211 | 211 | { |
212 | - if(file_exists(storage_path('.cbconfig'))) { |
|
212 | + if (file_exists(storage_path('.cbconfig'))) { |
|
213 | 213 | $settings = file_get_contents(storage_path('.cbconfig')); |
214 | 214 | $settings = unserialize($settings); |
215 | - }else{ |
|
215 | + } else { |
|
216 | 216 | $settings = []; |
217 | 217 | } |
218 | 218 | |
@@ -223,25 +223,25 @@ discard block |
||
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | -if(!function_exists('getSetting')) { |
|
226 | +if (!function_exists('getSetting')) { |
|
227 | 227 | function getSetting($key, $default = null) |
228 | 228 | { |
229 | - if(file_exists(storage_path('.cbconfig'))) { |
|
229 | + if (file_exists(storage_path('.cbconfig'))) { |
|
230 | 230 | $settings = file_get_contents(storage_path('.cbconfig')); |
231 | 231 | $settings = unserialize($settings); |
232 | - }else{ |
|
232 | + } else { |
|
233 | 233 | $settings = []; |
234 | 234 | } |
235 | 235 | |
236 | - if(isset($settings[$key])) { |
|
237 | - return $settings[$key]?:$default; |
|
238 | - }else{ |
|
236 | + if (isset($settings[$key])) { |
|
237 | + return $settings[$key] ?: $default; |
|
238 | + } else { |
|
239 | 239 | return $default; |
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | -if(!function_exists('timeAgo')) { |
|
244 | +if (!function_exists('timeAgo')) { |
|
245 | 245 | function timeAgo($datetime_to, $datetime_from = null, $full = false) |
246 | 246 | { |
247 | 247 | $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s'); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | - if (! $full) { |
|
275 | + if (!$full) { |
|
276 | 276 | $string = array_slice($string, 0, 1); |
277 | 277 | } |
278 | 278 | |
@@ -280,22 +280,22 @@ discard block |
||
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | -if(!function_exists("array_map_r")) { |
|
284 | - function array_map_r( $func, $arr ) |
|
283 | +if (!function_exists("array_map_r")) { |
|
284 | + function array_map_r($func, $arr) |
|
285 | 285 | { |
286 | 286 | $newArr = array(); |
287 | 287 | |
288 | - foreach( $arr as $key => $value ) |
|
288 | + foreach ($arr as $key => $value) |
|
289 | 289 | { |
290 | 290 | $key = $func($key); |
291 | - $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) ); |
|
291 | + $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value))); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | return $newArr; |
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | -if(!function_exists("sanitizeXSS")) |
|
298 | +if (!function_exists("sanitizeXSS")) |
|
299 | 299 | { |
300 | 300 | function sanitizeXSS($value) |
301 | 301 | { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | -if(!function_exists("requestAll")) { |
|
310 | +if (!function_exists("requestAll")) { |
|
311 | 311 | function requestAll() { |
312 | 312 | $all = array_map_r("sanitizeXSS", request()->all()); |
313 | 313 | return $all; |
@@ -316,22 +316,22 @@ discard block |
||
316 | 316 | |
317 | 317 | |
318 | 318 | |
319 | -if(!function_exists('getURLFormat')) { |
|
319 | +if (!function_exists('getURLFormat')) { |
|
320 | 320 | function getURLFormat($name) { |
321 | 321 | $url = request($name); |
322 | - if(filter_var($url, FILTER_VALIDATE_URL)) { |
|
322 | + if (filter_var($url, FILTER_VALIDATE_URL)) { |
|
323 | 323 | return $url; |
324 | - }else{ |
|
324 | + } else { |
|
325 | 325 | return request()->url(); |
326 | 326 | } |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | -if(!function_exists('g')) { |
|
330 | +if (!function_exists('g')) { |
|
331 | 331 | function g($name, $safe = true) { |
332 | - if($safe == true) { |
|
332 | + if ($safe == true) { |
|
333 | 333 | $response = request($name); |
334 | - if(is_string($response)) { |
|
334 | + if (is_string($response)) { |
|
335 | 335 | $response = sanitizeXSS($response); |
336 | 336 | }elseif (is_array($response)) { |
337 | 337 | array_walk_recursive($response, function(&$response) { |
@@ -340,25 +340,25 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | return $response; |
343 | - }else{ |
|
343 | + } else { |
|
344 | 344 | return Request::get($name); |
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | -if(!function_exists('min_var_export')) { |
|
349 | +if (!function_exists('min_var_export')) { |
|
350 | 350 | function min_var_export($input) { |
351 | - if(is_array($input)) { |
|
351 | + if (is_array($input)) { |
|
352 | 352 | $buffer = []; |
353 | - foreach($input as $key => $value) |
|
353 | + foreach ($input as $key => $value) |
|
354 | 354 | $buffer[] = var_export($key, true)."=>".min_var_export($value); |
355 | - return "[".implode(",",$buffer)."]"; |
|
355 | + return "[".implode(",", $buffer)."]"; |
|
356 | 356 | } else |
357 | 357 | return var_export($input, true); |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | -if(!function_exists('rrmdir')) { |
|
361 | +if (!function_exists('rrmdir')) { |
|
362 | 362 | /* |
363 | 363 | * http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir |
364 | 364 | */ |
@@ -41,7 +41,7 @@ |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | public function send() { |
44 | - Mail::send("crudbooster::emails.blank", ['content' => $this->content], function ($message) { |
|
44 | + Mail::send("crudbooster::emails.blank", ['content' => $this->content], function($message) { |
|
45 | 45 | $message->priority(1); |
46 | 46 | $message->to($this->to_email); |
47 | 47 | $message->from($this->sender_email, $this->sender_name); |
@@ -103,7 +103,7 @@ |
||
103 | 103 | } else { |
104 | 104 | throw new \Exception("Something went wrong, file can't upload!"); |
105 | 105 | } |
106 | - }else{ |
|
106 | + } else{ |
|
107 | 107 | throw new \Exception("The file format is not allowed!"); |
108 | 108 | } |
109 | 109 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | public function getRoleByName($roleName) { |
21 | - return $this->find("cb_roles",['name'=>$roleName]); |
|
21 | + return $this->find("cb_roles", ['name'=>$roleName]); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function fcm() { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | public function getDeveloperUrl($path = null) { |
37 | - $path = ($path)?"/".trim($path,"/"):null; |
|
37 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
38 | 38 | return url(cbConfig("DEV_PATH")).$path; |
39 | 39 | } |
40 | 40 | |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | public function getAdminUrl($path = null) { |
54 | - $path = ($path)?"/".trim($path,"/"):null; |
|
54 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
55 | 55 | return url(cbConfig("ADMIN_PATH")).$path; |
56 | 56 | } |
57 | 57 | |
58 | 58 | public function getAppName() { |
59 | - return env("APP_NAME","CRUDBOOSTER"); |
|
59 | + return env("APP_NAME", "CRUDBOOSTER"); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public function uploadBase64($value) |
63 | 63 | { |
64 | 64 | $fileData = base64_decode($value); |
65 | 65 | $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE); |
66 | - if($mime_type) { |
|
67 | - if($mime_type = explode('/', $mime_type)) { |
|
66 | + if ($mime_type) { |
|
67 | + if ($mime_type = explode('/', $mime_type)) { |
|
68 | 68 | $ext = $mime_type[1]; |
69 | - if($ext) { |
|
69 | + if ($ext) { |
|
70 | 70 | $filePath = 'uploads/'.date('Y-m'); |
71 | 71 | Storage::makeDirectory($filePath); |
72 | 72 | $filename = sha1(strRandom(5)).'.'.$ext; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $file = request()->file($name); |
88 | 88 | $ext = $file->getClientOriginalExtension(); |
89 | - if(in_array($ext,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
89 | + if (in_array($ext, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
90 | 90 | $filename = slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)); |
91 | 91 | $file_path = 'uploads/'.date('Y-m'); |
92 | 92 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | if (Storage::putFileAs($file_path, $file, $filename)) { |
103 | - if($resize_width || $resize_height) { |
|
103 | + if ($resize_width || $resize_height) { |
|
104 | 104 | $this->resizeImage($file_path.'/'.$filename, $resize_width, $resize_height); |
105 | 105 | } |
106 | 106 | return $file_path.'/'.$filename; |
107 | 107 | } else { |
108 | 108 | throw new \Exception("Something went wrong, file can't upload!"); |
109 | 109 | } |
110 | - }else{ |
|
110 | + } else { |
|
111 | 111 | throw new \Exception("The file format is not allowed!"); |
112 | 112 | } |
113 | 113 | |
@@ -130,22 +130,22 @@ discard block |
||
130 | 130 | $img = Image::make(storage_path('app/'.$file_path.'/'.$filename)); |
131 | 131 | $img->fit($resize_width, $resize_height); |
132 | 132 | $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty); |
133 | - } elseif ($resize_width && ! $resize_height) { |
|
133 | + } elseif ($resize_width && !$resize_height) { |
|
134 | 134 | $img = Image::make(storage_path('app/'.$file_path.'/'.$filename)); |
135 | - $img->resize($resize_width, null, function ($constraint) { |
|
135 | + $img->resize($resize_width, null, function($constraint) { |
|
136 | 136 | $constraint->aspectRatio(); |
137 | 137 | }); |
138 | 138 | $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty); |
139 | - } elseif (! $resize_width && $resize_height) { |
|
139 | + } elseif (!$resize_width && $resize_height) { |
|
140 | 140 | $img = Image::make(storage_path('app/'.$file_path.'/'.$filename)); |
141 | - $img->resize(null, $resize_height, function ($constraint) { |
|
141 | + $img->resize(null, $resize_height, function($constraint) { |
|
142 | 142 | $constraint->aspectRatio(); |
143 | 143 | }); |
144 | 144 | $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty); |
145 | 145 | } else { |
146 | 146 | $img = Image::make(storage_path('app/'.$file_path.'/'.$filename)); |
147 | 147 | if ($img->width() > 1300) { |
148 | - $img->resize(1300, null, function ($constraint) { |
|
148 | + $img->resize(1300, null, function($constraint) { |
|
149 | 149 | $constraint->aspectRatio(); |
150 | 150 | }); |
151 | 151 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $validator = Validator::make($input_arr, $rules, $messages); |
253 | 253 | if ($validator->fails()) { |
254 | 254 | $message = $validator->errors()->all(); |
255 | - throw new CBValidationException(implode("; ",$message)); |
|
255 | + throw new CBValidationException(implode("; ", $message)); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | public function findPrimaryKey($table) |
265 | 265 | { |
266 | 266 | $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey(); |
267 | - if(!$pk) { |
|
267 | + if (!$pk) { |
|
268 | 268 | return null; |
269 | 269 | } |
270 | 270 | return $pk->getColumns()[0]; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $string_parameters_array = explode('&', $string_parameters); |
314 | 314 | foreach ($string_parameters_array as $s) { |
315 | 315 | $part = explode('=', $s); |
316 | - if(isset($part[0]) && isset($part[1])) { |
|
316 | + if (isset($part[0]) && isset($part[1])) { |
|
317 | 317 | $name = htmlspecialchars(urldecode($part[0])); |
318 | 318 | $name = strip_tags($name); |
319 | 319 | $value = htmlspecialchars(urldecode($part[1])); |
@@ -330,16 +330,16 @@ discard block |
||
330 | 330 | |
331 | 331 | |
332 | 332 | public function routeGet($prefix, $controller) { |
333 | - $alias = str_replace("@"," ", $controller); |
|
333 | + $alias = str_replace("@", " ", $controller); |
|
334 | 334 | $alias = ucwords($alias); |
335 | - $alias = str_replace(" ","",$alias); |
|
335 | + $alias = str_replace(" ", "", $alias); |
|
336 | 336 | Route::get($prefix, ['uses' => $controller, 'as' => $alias]); |
337 | 337 | } |
338 | 338 | |
339 | 339 | public function routePost($prefix, $controller) { |
340 | - $alias = str_replace("@"," ", $controller); |
|
340 | + $alias = str_replace("@", " ", $controller); |
|
341 | 341 | $alias = ucwords($alias); |
342 | - $alias = str_replace(" ","",$alias); |
|
342 | + $alias = str_replace(" ", "", $alias); |
|
343 | 343 | Route::post($prefix, ['uses' => $controller, 'as' => $alias]); |
344 | 344 | } |
345 | 345 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | if ($this->confirm('Do you have setting the database configuration at .env ?')) { |
40 | 40 | |
41 | - if (! file_exists(public_path('vendor')) ) { |
|
41 | + if (!file_exists(public_path('vendor'))) { |
|
42 | 42 | mkdir(public_path('vendor'), 0777); |
43 | 43 | } |
44 | 44 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function assignment($value, $column) |
22 | 22 | { |
23 | - return implode(";", request( $column->getName() )); |
|
23 | + return implode(";", request($column->getName())); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
27 | 27 | \ No newline at end of file |