@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | $routeArray = request()->route()->getAction(); |
| 27 | 27 | $this->controller = class_basename($routeArray['controller']); |
| 28 | - $this->controller = strtok($this->controller,"@"); |
|
| 28 | + $this->controller = strtok($this->controller, "@"); |
|
| 29 | 29 | |
| 30 | 30 | $className = "\\".$routeArray["namespace"]."\\".$this->controller; |
| 31 | - if(class_exists($className)) { |
|
| 32 | - $this->module = cb()->find("cb_modules",["controller"=>$this->controller]); |
|
| 33 | - if($this->module) { |
|
| 31 | + if (class_exists($className)) { |
|
| 32 | + $this->module = cb()->find("cb_modules", ["controller"=>$this->controller]); |
|
| 33 | + if ($this->module) { |
|
| 34 | 34 | $this->controller_class = new $className(); |
| 35 | - $this->menu = cb()->find("cb_menus",["cb_modules_id"=>$this->module->id]); |
|
| 36 | - $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu; |
|
| 37 | - if($this->menu) { |
|
| 35 | + $this->menu = cb()->find("cb_menus", ["cb_modules_id"=>$this->module->id]); |
|
| 36 | + $this->menu = (!$this->menu) ?cb()->find("cb_menus", ["type"=>"path", "path"=>request()->segment(2)]) : $this->menu; |
|
| 37 | + if ($this->menu) { |
|
| 38 | 38 | $this->privilege = DB::table("cb_role_privileges") |
| 39 | 39 | ->where("cb_menus_id", $this->menu->id) |
| 40 | 40 | ->where("cb_roles_id", cb()->session()->roleId()) |
@@ -53,135 +53,135 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function getData($key) { |
| 56 | - return ($this->controller_class)?$this->controller_class->getData($key)?:cb()->getAppName():null; |
|
| 56 | + return ($this->controller_class) ? $this->controller_class->getData($key) ?: cb()->getAppName() : null; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @return CBController |
| 61 | 61 | */ |
| 62 | 62 | public function getController() { |
| 63 | - return ($this->controller_class)?$this->controller_class:null; |
|
| 63 | + return ($this->controller_class) ? $this->controller_class : null; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function getPageTitle() |
| 67 | 67 | { |
| 68 | - return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null; |
|
| 68 | + return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | public function getTable() |
| 72 | 72 | { |
| 73 | - return ($this->controller_class)?$this->controller_class->getData("table"):null; |
|
| 73 | + return ($this->controller_class) ? $this->controller_class->getData("table") : null; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function getPageIcon() |
| 77 | 77 | { |
| 78 | - return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null; |
|
| 78 | + return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function canBrowse() { |
| 82 | - if($this->privilege) { |
|
| 83 | - if($this->privilege->can_browse) return true; |
|
| 82 | + if ($this->privilege) { |
|
| 83 | + if ($this->privilege->can_browse) return true; |
|
| 84 | 84 | else return false; |
| 85 | - }else{ |
|
| 85 | + } else { |
|
| 86 | 86 | return true; |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | public function canCreate() { |
| 91 | - if($this->privilege) { |
|
| 92 | - if($this->privilege->can_create) return true; |
|
| 91 | + if ($this->privilege) { |
|
| 92 | + if ($this->privilege->can_create) return true; |
|
| 93 | 93 | else return false; |
| 94 | - }else{ |
|
| 94 | + } else { |
|
| 95 | 95 | return true; |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public function canRead() { |
| 100 | - if($this->privilege) { |
|
| 101 | - if($this->privilege->can_read) return true; |
|
| 100 | + if ($this->privilege) { |
|
| 101 | + if ($this->privilege->can_read) return true; |
|
| 102 | 102 | else return false; |
| 103 | - }else{ |
|
| 103 | + } else { |
|
| 104 | 104 | return true; |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public function canUpdate() { |
| 109 | - if($this->privilege) { |
|
| 110 | - if($this->privilege->can_update) return true; |
|
| 109 | + if ($this->privilege) { |
|
| 110 | + if ($this->privilege->can_update) return true; |
|
| 111 | 111 | else return false; |
| 112 | - }else{ |
|
| 112 | + } else { |
|
| 113 | 113 | return true; |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function canDelete() { |
| 118 | - if($this->privilege) { |
|
| 119 | - if($this->privilege->can_delete) return true; |
|
| 118 | + if ($this->privilege) { |
|
| 119 | + if ($this->privilege->can_delete) return true; |
|
| 120 | 120 | else return false; |
| 121 | - }else{ |
|
| 121 | + } else { |
|
| 122 | 122 | return true; |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | public function addURL() |
| 127 | 127 | { |
| 128 | - if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
| 128 | + if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
| 129 | 129 | return action($this->controller.'@getAdd'); |
| 130 | - }else{ |
|
| 130 | + } else { |
|
| 131 | 131 | return null; |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | public function addSaveURL() |
| 136 | 136 | { |
| 137 | - if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
| 137 | + if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
| 138 | 138 | return action($this->controller.'@postAddSave'); |
| 139 | - }else{ |
|
| 139 | + } else { |
|
| 140 | 140 | return null; |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | public function editURL($id = null) |
| 145 | 145 | { |
| 146 | - if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
| 147 | - return action($this->controller.'@getEdit',['id'=>$id]); |
|
| 148 | - }else{ |
|
| 146 | + if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
| 147 | + return action($this->controller.'@getEdit', ['id'=>$id]); |
|
| 148 | + } else { |
|
| 149 | 149 | return null; |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public function editSaveURL($id = null) |
| 154 | 154 | { |
| 155 | - if(method_exists($this->controller_class, 'postEditSave')) { |
|
| 156 | - return action($this->controller.'@postEditSave',['id'=>$id]); |
|
| 157 | - }else{ |
|
| 155 | + if (method_exists($this->controller_class, 'postEditSave')) { |
|
| 156 | + return action($this->controller.'@postEditSave', ['id'=>$id]); |
|
| 157 | + } else { |
|
| 158 | 158 | return null; |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public function detailURL($id=null) |
|
| 162 | + public function detailURL($id = null) |
|
| 163 | 163 | { |
| 164 | - if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
| 165 | - return action($this->controller.'@getDetail',['id'=>$id]); |
|
| 166 | - }else{ |
|
| 164 | + if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
| 165 | + return action($this->controller.'@getDetail', ['id'=>$id]); |
|
| 166 | + } else { |
|
| 167 | 167 | return null; |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - public function deleteURL($id=null) |
|
| 171 | + public function deleteURL($id = null) |
|
| 172 | 172 | { |
| 173 | - if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
| 174 | - return action($this->controller.'@getDelete',['id'=>$id]); |
|
| 175 | - }else{ |
|
| 173 | + if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
| 174 | + return action($this->controller.'@getDelete', ['id'=>$id]); |
|
| 175 | + } else { |
|
| 176 | 176 | return null; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | public function url($path = null) |
| 181 | 181 | { |
| 182 | - if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
| 183 | - return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
|
| 184 | - }else{ |
|
| 182 | + if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
| 183 | + return trim(action($this->controller.'@getIndex').'/'.$path, '/'); |
|
| 184 | + } else { |
|
| 185 | 185 | return null; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -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 | |
@@ -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()->has('password')) { |
|
| 29 | + if (request()->has('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 | } |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function __call($method, $parameters) |
| 29 | 29 | { |
| 30 | - if($method == "getData") { |
|
| 30 | + if ($method == "getData") { |
|
| 31 | 31 | $key = $parameters[0]; |
| 32 | - if(isset($this->data[$key])) { |
|
| 32 | + if (isset($this->data[$key])) { |
|
| 33 | 33 | return $this->data[$key]; |
| 34 | - }else{ |
|
| 34 | + } else { |
|
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | - }else{ |
|
| 37 | + } else { |
|
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -49,19 +49,19 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
| 51 | 51 | |
| 52 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
| 52 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
| 53 | 53 | { |
| 54 | 54 | $query = call_user_func($this->data['hook_query_index'], $query); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
| 58 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
| 57 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
| 58 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
| 59 | 59 | $query->whereNull($this->data['table'].'.deleted_at'); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
| 63 | - if(isset($joins)) { |
|
| 64 | - foreach($joins as $join) |
|
| 63 | + if (isset($joins)) { |
|
| 64 | + foreach ($joins as $join) |
|
| 65 | 65 | { |
| 66 | 66 | $query->join($join['target_table'], |
| 67 | 67 | $join['target_table_primary'], |
@@ -71,31 +71,31 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - foreach($columns as $column) { |
|
| 74 | + foreach ($columns as $column) { |
|
| 75 | 75 | /** @var ColumnModel $column */ |
| 76 | - if(strpos($column->getField(),".") === false) { |
|
| 76 | + if (strpos($column->getField(), ".") === false) { |
|
| 77 | 77 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 78 | - }else{ |
|
| 78 | + } else { |
|
| 79 | 79 | $query->addSelect($column->getField()); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $query = getTypeHook($column->getType())->query($query, $column); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if(request()->has('q')) |
|
| 85 | + if (request()->has('q')) |
|
| 86 | 86 | { |
| 87 | - if(isset($this->data['hook_search_query'])) { |
|
| 87 | + if (isset($this->data['hook_search_query'])) { |
|
| 88 | 88 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 89 | - }else{ |
|
| 90 | - $query->where(function ($where) use ($columns) { |
|
| 89 | + } else { |
|
| 90 | + $query->where(function($where) use ($columns) { |
|
| 91 | 91 | /** |
| 92 | 92 | * @var $where Builder |
| 93 | 93 | */ |
| 94 | - foreach($columns as $column) |
|
| 94 | + foreach ($columns as $column) |
|
| 95 | 95 | { |
| 96 | - if(strpos($column->getField(),".") === false) { |
|
| 96 | + if (strpos($column->getField(), ".") === false) { |
|
| 97 | 97 | $field = $this->data['table'].'.'.$column->getField(); |
| 98 | - }else{ |
|
| 98 | + } else { |
|
| 99 | 99 | $field = $column->getField(); |
| 100 | 100 | } |
| 101 | 101 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
| 107 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
| 108 | 108 | $query = call_user_func($this->data['hook_query_index'], $query); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - if(request()->has(['order_by','order_sort'])) |
|
| 112 | + if (request()->has(['order_by', 'order_sort'])) |
|
| 113 | 113 | { |
| 114 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
| 114 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
| 115 | 115 | $query->orderBy(request('order_by'), request('order_sort')); |
| 116 | 116 | } |
| 117 | - }else{ |
|
| 117 | + } else { |
|
| 118 | 118 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | public function getIndex() |
| 125 | 125 | { |
| 126 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 126 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
| 127 | 127 | |
| 128 | 128 | $query = $this->repository(); |
| 129 | 129 | $result = $query->paginate(20); |
@@ -137,51 +137,51 @@ 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 access to this area"); |
|
| 152 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have 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',$data); |
|
| 157 | + return view('crudbooster::module.form.form', $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 access to this area"); |
|
| 162 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
| 163 | 163 | |
| 164 | 164 | try { |
| 165 | 165 | $this->validation(); |
| 166 | 166 | columnSingleton()->valueAssignment(); |
| 167 | 167 | $data = columnSingleton()->getAssignmentData(); |
| 168 | 168 | |
| 169 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
| 169 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
| 170 | 170 | $data['created_at'] = date('Y-m-d H:i:s'); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $id = DB::table($this->data['table'])->insertGetId($data); |
| 174 | 174 | |
| 175 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
| 175 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
| 176 | 176 | call_user_func($this->data['hook_after_insert'], $id); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | } catch (CBValidationException $e) { |
| 180 | 180 | Log::debug($e); |
| 181 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
| 181 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
| 182 | 182 | } catch (\Exception $e) { |
| 183 | 183 | Log::error($e); |
| 184 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
| 184 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | if (request('submit') == trans('crudbooster.button_save_more')) { |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | public function getEdit($id) |
| 195 | 195 | { |
| 196 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 196 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
| 197 | 197 | |
| 198 | 198 | $data = []; |
| 199 | 199 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -204,17 +204,17 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | public function postEditSave($id) |
| 206 | 206 | { |
| 207 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 207 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
| 208 | 208 | |
| 209 | 209 | try { |
| 210 | 210 | $this->validation(); |
| 211 | 211 | columnSingleton()->valueAssignment(); |
| 212 | 212 | $data = columnSingleton()->getAssignmentData(); |
| 213 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 213 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 214 | 214 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
| 217 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
| 218 | 218 | call_user_func($this->data['hook_before_update'], $id); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -222,16 +222,16 @@ discard block |
||
| 222 | 222 | ->where(cb()->pk($this->data['table']), $id) |
| 223 | 223 | ->update($data); |
| 224 | 224 | |
| 225 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
| 225 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
| 226 | 226 | call_user_func($this->data['hook_after_update'], $id); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | } catch (CBValidationException $e) { |
| 230 | 230 | Log::debug($e); |
| 231 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
| 231 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
| 232 | 232 | } catch (\Exception $e) { |
| 233 | 233 | Log::error($e); |
| 234 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
| 234 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
@@ -244,15 +244,15 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | public function getDelete($id) |
| 246 | 246 | { |
| 247 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 247 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
| 248 | 248 | |
| 249 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
| 249 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
| 250 | 250 | call_user_func($this->data['hook_before_delete'], $id); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
| 253 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
| 254 | 254 | |
| 255 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
| 255 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
| 256 | 256 | DB::table($this->data['table']) |
| 257 | 257 | ->where(getPrimaryKey($this->data['table']), $id) |
| 258 | 258 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | ->delete(); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
| 265 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
| 266 | 266 | call_user_func($this->data['hook_after_delete'], $id); |
| 267 | 267 | } |
| 268 | 268 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | public function getDetail($id) |
| 273 | 273 | { |
| 274 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 274 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
| 275 | 275 | |
| 276 | 276 | $data = []; |
| 277 | 277 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -281,21 +281,21 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | public function postUploadFile() |
| 283 | 283 | { |
| 284 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
| 284 | + if (auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
| 285 | 285 | |
| 286 | 286 | $file = null; |
| 287 | 287 | try { |
| 288 | 288 | |
| 289 | 289 | cb()->validation([ |
| 290 | - 'userfile' => 'required|mimes:' . config('crudbooster.UPLOAD_TYPES') |
|
| 290 | + 'userfile' => 'required|mimes:'.config('crudbooster.UPLOAD_TYPES') |
|
| 291 | 291 | ]); |
| 292 | 292 | |
| 293 | 293 | $file = cb()->uploadFile('userfile', true); |
| 294 | 294 | |
| 295 | 295 | } catch (CBValidationException $e) { |
| 296 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
| 296 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
| 297 | 297 | } catch (\Exception $e) { |
| 298 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
| 298 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | return response()->json([ |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | $key = $parameters[0]; |
| 32 | 32 | if(isset($this->data[$key])) { |
| 33 | 33 | return $this->data[$key]; |
| 34 | - }else{ |
|
| 34 | + } else{ |
|
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | - }else{ |
|
| 37 | + } else{ |
|
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** @var ColumnModel $column */ |
| 76 | 76 | if(strpos($column->getField(),".") === false) { |
| 77 | 77 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 78 | - }else{ |
|
| 78 | + } else{ |
|
| 79 | 79 | $query->addSelect($column->getField()); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | if(isset($this->data['hook_search_query'])) { |
| 88 | 88 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 89 | - }else{ |
|
| 89 | + } else{ |
|
| 90 | 90 | $query->where(function ($where) use ($columns) { |
| 91 | 91 | /** |
| 92 | 92 | * @var $where Builder |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | if(strpos($column->getField(),".") === false) { |
| 97 | 97 | $field = $this->data['table'].'.'.$column->getField(); |
| 98 | - }else{ |
|
| 98 | + } else{ |
|
| 99 | 99 | $field = $column->getField(); |
| 100 | 100 | } |
| 101 | 101 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
| 115 | 115 | $query->orderBy(request('order_by'), request('order_sort')); |
| 116 | 116 | } |
| 117 | - }else{ |
|
| 117 | + } else{ |
|
| 118 | 118 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,7 +123,9 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | public function getIndex() |
| 125 | 125 | { |
| 126 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 126 | + if(!module()->canBrowse()) { |
|
| 127 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 128 | + } |
|
| 127 | 129 | |
| 128 | 130 | $query = $this->repository(); |
| 129 | 131 | $result = $query->paginate(20); |
@@ -149,7 +151,9 @@ discard block |
||
| 149 | 151 | |
| 150 | 152 | public function getAdd() |
| 151 | 153 | { |
| 152 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 154 | + if(!module()->canCreate()) { |
|
| 155 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 156 | + } |
|
| 153 | 157 | |
| 154 | 158 | $data = []; |
| 155 | 159 | $data['page_title'] = $this->data['page_title'].' : Add'; |
@@ -159,7 +163,9 @@ discard block |
||
| 159 | 163 | |
| 160 | 164 | public function postAddSave() |
| 161 | 165 | { |
| 162 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 166 | + if(!module()->canCreate()) { |
|
| 167 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 168 | + } |
|
| 163 | 169 | |
| 164 | 170 | try { |
| 165 | 171 | $this->validation(); |
@@ -193,7 +199,9 @@ discard block |
||
| 193 | 199 | |
| 194 | 200 | public function getEdit($id) |
| 195 | 201 | { |
| 196 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 202 | + if(!module()->canUpdate()) { |
|
| 203 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 204 | + } |
|
| 197 | 205 | |
| 198 | 206 | $data = []; |
| 199 | 207 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -204,7 +212,9 @@ discard block |
||
| 204 | 212 | |
| 205 | 213 | public function postEditSave($id) |
| 206 | 214 | { |
| 207 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 215 | + if(!module()->canUpdate()) { |
|
| 216 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 217 | + } |
|
| 208 | 218 | |
| 209 | 219 | try { |
| 210 | 220 | $this->validation(); |
@@ -244,7 +254,9 @@ discard block |
||
| 244 | 254 | |
| 245 | 255 | public function getDelete($id) |
| 246 | 256 | { |
| 247 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 257 | + if(!module()->canDelete()) { |
|
| 258 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 259 | + } |
|
| 248 | 260 | |
| 249 | 261 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
| 250 | 262 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -271,7 +283,9 @@ discard block |
||
| 271 | 283 | |
| 272 | 284 | public function getDetail($id) |
| 273 | 285 | { |
| 274 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 286 | + if(!module()->canRead()) { |
|
| 287 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 288 | + } |
|
| 275 | 289 | |
| 276 | 290 | $data = []; |
| 277 | 291 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -281,7 +295,9 @@ discard block |
||
| 281 | 295 | |
| 282 | 296 | public function postUploadFile() |
| 283 | 297 | { |
| 284 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
| 298 | + if(auth()->guest()) { |
|
| 299 | + return redirect(cb()->getLoginUrl()); |
|
| 300 | + } |
|
| 285 | 301 | |
| 286 | 302 | $file = null; |
| 287 | 303 | try { |
@@ -1,32 +1,32 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Developer Backend Middleware |
| 4 | -Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
| 4 | +Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
| 5 | 5 | 'prefix'=>cbConfig('DEV_PATH'), |
| 6 | - 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
| 7 | - cb()->routeController("modules", "DeveloperModulesController",'crocodicstudio\crudbooster\controllers'); |
|
| 8 | - cb()->routeController("menus", "DeveloperMenusController",'crocodicstudio\crudbooster\controllers'); |
|
| 9 | - cb()->routeController("roles","DeveloperRolesController",'crocodicstudio\crudbooster\controllers'); |
|
| 10 | - cb()->routeController("users","DeveloperUsersController",'crocodicstudio\crudbooster\controllers'); |
|
| 11 | - cb()->routeGet("/","DeveloperDashboardController@getIndex"); |
|
| 6 | + 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
| 7 | + cb()->routeController("modules", "DeveloperModulesController", 'crocodicstudio\crudbooster\controllers'); |
|
| 8 | + cb()->routeController("menus", "DeveloperMenusController", 'crocodicstudio\crudbooster\controllers'); |
|
| 9 | + cb()->routeController("roles", "DeveloperRolesController", 'crocodicstudio\crudbooster\controllers'); |
|
| 10 | + cb()->routeController("users", "DeveloperUsersController", 'crocodicstudio\crudbooster\controllers'); |
|
| 11 | + cb()->routeGet("/", "DeveloperDashboardController@getIndex"); |
|
| 12 | 12 | }); |
| 13 | 13 | |
| 14 | 14 | // Developer Auth Middleware |
| 15 | 15 | Route::group(['middleware' => ['web'], |
| 16 | 16 | 'prefix'=>cbConfig('DEV_PATH'), |
| 17 | - 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
| 18 | - cb()->routePost("login","AdminAuthController@postLoginDeveloper"); |
|
| 19 | - cb()->routeGet("login","AdminAuthController@getLoginDeveloper"); |
|
| 20 | - cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper"); |
|
| 17 | + 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
| 18 | + cb()->routePost("login", "AdminAuthController@postLoginDeveloper"); |
|
| 19 | + cb()->routeGet("login", "AdminAuthController@getLoginDeveloper"); |
|
| 20 | + cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper"); |
|
| 21 | 21 | }); |
| 22 | 22 | |
| 23 | 23 | // Routing without any middleware |
| 24 | -Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () { |
|
| 24 | +Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() { |
|
| 25 | 25 | cb()->routeGet('uploads/{one?}/{two?}/{three?}/{four?}/{five?}', "FileController@getPreview"); |
| 26 | 26 | }); |
| 27 | 27 | |
| 28 | 28 | // Routing without any middleware with admin prefix |
| 29 | -Route::group(['middleware' => ['web'], 'prefix' => cbConfig('ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
| 29 | +Route::group(['middleware' => ['web'], 'prefix' => cbConfig('ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
| 30 | 30 | cb()->routeGet('logout', "AdminAuthController@getLogout"); |
| 31 | 31 | cb()->routePost('login', "AdminAuthController@postLogin"); |
| 32 | 32 | cb()->routeGet('login', "AdminAuthController@getLogin"); |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | 'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class], |
| 38 | 38 | 'prefix' => cbConfig('ADMIN_PATH'), |
| 39 | 39 | 'namespace' => 'crocodicstudio\crudbooster\controllers', |
| 40 | -], function () { |
|
| 41 | - cb()->routeController('profile', 'AdminProfileController','crocodicstudio\crudbooster\controllers'); |
|
| 40 | +], function() { |
|
| 41 | + cb()->routeController('profile', 'AdminProfileController', 'crocodicstudio\crudbooster\controllers'); |
|
| 42 | 42 | }); |
| 43 | 43 | |
| 44 | 44 | // Auto Routing for App\Http\Controllers |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | 'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class], |
| 47 | 47 | 'prefix' => cbConfig('ADMIN_PATH'), |
| 48 | 48 | 'namespace' => 'App\Http\Controllers', |
| 49 | -], function () { |
|
| 49 | +], function() { |
|
| 50 | 50 | |
| 51 | 51 | if (Request::is(cbConfig('ADMIN_PATH'))) { |
| 52 | - if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
|
| 52 | + if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
|
| 53 | 53 | cb()->routeGet("/", $dashboard); |
| 54 | - }else{ |
|
| 54 | + } else { |
|
| 55 | 55 | cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $controllers = glob(app_path('Http/Controllers/Admin*Controller.php')); |
| 60 | 60 | |
| 61 | - foreach($controllers as $controller) { |
|
| 61 | + foreach ($controllers as $controller) { |
|
| 62 | 62 | $controllerName = basename($controller); |
| 63 | - $controllerName = rtrim($controllerName,".php"); |
|
| 63 | + $controllerName = rtrim($controllerName, ".php"); |
|
| 64 | 64 | $className = '\App\Http\Controllers\\'.$controllerName; |
| 65 | 65 | $controllerClass = new $className(); |
| 66 | - if(method_exists($controllerClass, 'cbInit')) { |
|
| 66 | + if (method_exists($controllerClass, 'cbInit')) { |
|
| 67 | 67 | cb()->routeController($controllerClass->getData('permalink'), $controllerName); |
| 68 | 68 | } |
| 69 | 69 | } |