@@ -49,7 +49,7 @@ |
||
49 | 49 | if (Request::is(cbConfig('ADMIN_PATH'))) { |
50 | 50 | if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
51 | 51 | Route::get("/", $dashboard); |
52 | - }else{ |
|
52 | + } else{ |
|
53 | 53 | Route::get("/", "crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
54 | 54 | } |
55 | 55 | } |
@@ -1,30 +1,30 @@ 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 () { |
|
6 | + 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
7 | 7 | cb()->routeController("modules", "DeveloperModulesController"); |
8 | 8 | cb()->routeController("menus", "DeveloperMenusController"); |
9 | - cb()->routeController("roles","DeveloperRolesController"); |
|
9 | + cb()->routeController("roles", "DeveloperRolesController"); |
|
10 | 10 | }); |
11 | 11 | |
12 | 12 | // Developer Auth Middleware |
13 | 13 | Route::group(['middleware' => ['web'], |
14 | 14 | 'prefix'=>cbConfig('DEV_PATH'), |
15 | - 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
16 | - Route::post("login","AdminAuthController@postLoginDeveloper"); |
|
17 | - Route::get("login","AdminAuthController@getLoginDeveloper"); |
|
18 | - Route::get("logout","AdminAuthController@getLogoutDeveloper"); |
|
15 | + 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
16 | + Route::post("login", "AdminAuthController@postLoginDeveloper"); |
|
17 | + Route::get("login", "AdminAuthController@getLoginDeveloper"); |
|
18 | + Route::get("logout", "AdminAuthController@getLogoutDeveloper"); |
|
19 | 19 | }); |
20 | 20 | |
21 | 21 | // Routing without any middleware |
22 | -Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () { |
|
22 | +Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() { |
|
23 | 23 | Route::get('uploads/{one?}/{two?}/{three?}/{four?}/{five?}', ['uses' => 'FileController@getPreview', 'as' => 'fileControllerPreview']); |
24 | 24 | }); |
25 | 25 | |
26 | 26 | // Routing without any middleware with admin prefix |
27 | -Route::group(['middleware' => ['web'], 'prefix' => cbConfig('ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
27 | +Route::group(['middleware' => ['web'], 'prefix' => cbConfig('ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
28 | 28 | Route::get('logout', ['uses' => 'AdminAuthController@getLogout', 'as' => 'getLogout']); |
29 | 29 | Route::post('login', ['uses' => 'AdminAuthController@postLogin', 'as' => 'postLogin']); |
30 | 30 | Route::get('login', ['uses' => 'AdminAuthController@getLogin', 'as' => 'getLogin']); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class], |
36 | 36 | 'prefix' => cbConfig('ADMIN_PATH'), |
37 | 37 | 'namespace' => 'crocodicstudio\crudbooster\controllers', |
38 | -], function () { |
|
38 | +], function() { |
|
39 | 39 | cb()->routeController('profile', 'AdminProfileController'); |
40 | 40 | }); |
41 | 41 | |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | 'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class], |
45 | 45 | 'prefix' => cbConfig('ADMIN_PATH'), |
46 | 46 | 'namespace' => 'App\Http\Controllers', |
47 | -], function () { |
|
47 | +], function() { |
|
48 | 48 | |
49 | 49 | if (Request::is(cbConfig('ADMIN_PATH'))) { |
50 | - if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
|
50 | + if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
|
51 | 51 | Route::get("/", $dashboard); |
52 | - }else{ |
|
52 | + } else { |
|
53 | 53 | Route::get("/", "crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | 57 | $controllers = glob(app_path('Http/Controllers/Admin*Controller.php')); |
58 | - foreach($controllers as $controller) { |
|
58 | + foreach ($controllers as $controller) { |
|
59 | 59 | $controllerName = basename($controller); |
60 | 60 | $className = '\App\Http\Controllers\\'.$controllerName; |
61 | 61 | $controllerClass = new $className(); |
62 | - if(method_exists($controllerClass, 'cbInit')) { |
|
62 | + if (method_exists($controllerClass, 'cbInit')) { |
|
63 | 63 | cb()->routeController($controllerClass->getData('permalink'), $controllerName); |
64 | 64 | } |
65 | 65 | } |
@@ -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 |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @param ButtonColor $color |
85 | 85 | * @param string $attributes |
86 | 86 | */ |
87 | - public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null) |
|
87 | + public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null) |
|
88 | 88 | { |
89 | - $color = ($color)?:ButtonColor::DARK_BLUE; |
|
89 | + $color = ($color) ?: ButtonColor::DARK_BLUE; |
|
90 | 90 | |
91 | 91 | $model = new IndexActionButtonModel(); |
92 | 92 | $model->setLabel($label); |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | * @param $fontAwesome_icon |
129 | 129 | * @param ButtonColor|string $color |
130 | 130 | */ |
131 | - public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false) |
|
131 | + public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false) |
|
132 | 132 | { |
133 | 133 | $new = new AddActionButtonModel(); |
134 | 134 | $new->setLabel($label); |
135 | - $new->setIcon($fontAwesome_icon?:"fa fa-bars"); |
|
136 | - $new->setColor($color?:"primary"); |
|
135 | + $new->setIcon($fontAwesome_icon ?: "fa fa-bars"); |
|
136 | + $new->setColor($color ?: "primary"); |
|
137 | 137 | $new->setUrl($url_target); |
138 | 138 | $new->setCondition($condition_callback); |
139 | 139 | $new->setConfirmation($confirmation); |
@@ -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); |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | public function getIndex() { |
21 | 21 | $data = []; |
22 | 22 | $data['result'] = DB::table("cb_roles")->get(); |
23 | - return view($this->view.".index",$data); |
|
23 | + return view($this->view.".index", $data); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getAdd() { |
27 | 27 | $data = []; |
28 | - $data['menus'] = DB::table("cb_menus")->orderBy("name","asc")->get(); |
|
28 | + $data['menus'] = DB::table("cb_menus")->orderBy("name", "asc")->get(); |
|
29 | 29 | return view($this->view.".add", $data); |
30 | 30 | } |
31 | 31 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | $privilege = []; |
44 | 44 | $privilege["cb_roles_id"] = $roles_id; |
45 | 45 | $privilege["cb_menus_id"] = $menus_id; |
46 | - $privilege["can_browse"] = $menu['can_browse']?:0; |
|
47 | - $privilege["can_create"] = $menu['can_create']?:0; |
|
48 | - $privilege["can_read"] = $menu['can_read']?:0; |
|
49 | - $privilege["can_update"] = $menu['can_update']?:0; |
|
50 | - $privilege["can_delete"] = $menu['can_delete']?:0; |
|
46 | + $privilege["can_browse"] = $menu['can_browse'] ?: 0; |
|
47 | + $privilege["can_create"] = $menu['can_create'] ?: 0; |
|
48 | + $privilege["can_read"] = $menu['can_read'] ?: 0; |
|
49 | + $privilege["can_update"] = $menu['can_update'] ?: 0; |
|
50 | + $privilege["can_delete"] = $menu['can_delete'] ?: 0; |
|
51 | 51 | DB::table("cb_role_privileges")->insert($privilege); |
52 | 52 | } |
53 | 53 | |
@@ -66,21 +66,21 @@ discard block |
||
66 | 66 | $data['row'] = cb()->find("cb_roles", $id); |
67 | 67 | |
68 | 68 | $menus = DB::table("cb_menus") |
69 | - ->leftjoin("cb_role_privileges",function($join) use ($id) { |
|
70 | - $join->on("cb_role_privileges.cb_menus_id","=","cb_menus.id")->where("cb_role_privileges.cb_roles_id", $id); |
|
69 | + ->leftjoin("cb_role_privileges", function($join) use ($id) { |
|
70 | + $join->on("cb_role_privileges.cb_menus_id", "=", "cb_menus.id")->where("cb_role_privileges.cb_roles_id", $id); |
|
71 | 71 | }) |
72 | - ->orderBy("cb_menus.name","asc") |
|
73 | - ->select("cb_menus.*","can_browse","can_create","can_read","can_update","can_delete") |
|
72 | + ->orderBy("cb_menus.name", "asc") |
|
73 | + ->select("cb_menus.*", "can_browse", "can_create", "can_read", "can_update", "can_delete") |
|
74 | 74 | ->get(); |
75 | 75 | $data['menus'] = $menus; |
76 | 76 | |
77 | - return view($this->view.".edit",$data); |
|
77 | + return view($this->view.".edit", $data); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | private function existsPrivilege($cb_roles_id, $cb_menus_id) { |
81 | - if($row = cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id])) { |
|
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 | } |
@@ -89,25 +89,25 @@ discard block |
||
89 | 89 | try { |
90 | 90 | cb()->validation(['name', 'menus']); |
91 | 91 | |
92 | - cb()->updateCompact("cb_roles",$id,['name']); |
|
92 | + cb()->updateCompact("cb_roles", $id, ['name']); |
|
93 | 93 | |
94 | 94 | foreach (request("menus") as $menus_id => $menu) { |
95 | 95 | $privilege = []; |
96 | 96 | $privilege["cb_roles_id"] = $id; |
97 | 97 | $privilege["cb_menus_id"] = $menus_id; |
98 | - $privilege["can_browse"] = $menu['can_browse']?:0; |
|
99 | - $privilege["can_create"] = $menu['can_create']?:0; |
|
100 | - $privilege["can_read"] = $menu['can_read']?:0; |
|
101 | - $privilege["can_update"] = $menu['can_update']?:0; |
|
102 | - $privilege["can_delete"] = $menu['can_delete']?:0; |
|
103 | - if($privilege_id = $this->existsPrivilege($id, $menus_id)) { |
|
98 | + $privilege["can_browse"] = $menu['can_browse'] ?: 0; |
|
99 | + $privilege["can_create"] = $menu['can_create'] ?: 0; |
|
100 | + $privilege["can_read"] = $menu['can_read'] ?: 0; |
|
101 | + $privilege["can_update"] = $menu['can_update'] ?: 0; |
|
102 | + $privilege["can_delete"] = $menu['can_delete'] ?: 0; |
|
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 | } |
109 | 109 | |
110 | - return cb()->redirect(action("DeveloperRolesController@getIndex"),"The role has been saved!","success"); |
|
110 | + return cb()->redirect(action("DeveloperRolesController@getIndex"), "The role has been saved!", "success"); |
|
111 | 111 | |
112 | 112 | } catch (CBValidationException $e) { |
113 | 113 | |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | |
118 | 118 | public function getDelete($id) { |
119 | 119 | DB::table("cb_roles")->where("id", $id)->delete(); |
120 | - DB::table("cb_role_privileges")->where("cb_roles_id",$id)->delete(); |
|
120 | + DB::table("cb_role_privileges")->where("cb_roles_id", $id)->delete(); |
|
121 | 121 | |
122 | - return cb()->redirectBack("The role has been deleted!","success"); |
|
122 | + return cb()->redirectBack("The role has been deleted!", "success"); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | } |
126 | 126 | \ No newline at end of file |
@@ -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 | } |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | $data = new ColumnModel(); |
33 | 33 | $data = $this->setDefaultModelValue($data); |
34 | 34 | $data->setLabel($label); |
35 | - $data->setName($this->name($label,$name)); |
|
36 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
35 | + $data->setName($this->name($label, $name)); |
|
36 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
37 | 37 | $data->setType("text"); |
38 | 38 | |
39 | 39 | columnSingleton()->setColumn($this->index, $data); |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | $data = new CheckboxModel(); |
49 | 49 | $data = $this->setDefaultModelValue($data); |
50 | 50 | $data->setLabel($label); |
51 | - $data->setName($this->name($label,$name)); |
|
52 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
51 | + $data->setName($this->name($label, $name)); |
|
52 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
53 | 53 | $data->setType("checkbox"); |
54 | 54 | |
55 | 55 | columnSingleton()->setColumn($this->index, $data); |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $data = new PasswordModel(); |
65 | 65 | $data = $this->setDefaultModelValue($data); |
66 | 66 | $data->setLabel($label); |
67 | - $data->setName($this->name($label,$name)); |
|
68 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
67 | + $data->setName($this->name($label, $name)); |
|
68 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
69 | 69 | $data->setType("password"); |
70 | 70 | $data->setShowDetail(false); |
71 | 71 | $data->setShowIndex(false); |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | $data = new ImageModel(); |
83 | 83 | $data = $this->setDefaultModelValue($data); |
84 | 84 | $data->setLabel($label); |
85 | - $data->setName($this->name($label,$name)); |
|
86 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
85 | + $data->setName($this->name($label, $name)); |
|
86 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
87 | 87 | $data->setType("image"); |
88 | 88 | |
89 | 89 | columnSingleton()->setColumn($this->index, $data); |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | $data = new TextAreaModel(); |
99 | 99 | $data = $this->setDefaultModelValue($data); |
100 | 100 | $data->setLabel($label); |
101 | - $data->setName($this->name($label,$name)); |
|
102 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
101 | + $data->setName($this->name($label, $name)); |
|
102 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
103 | 103 | $data->setType("text_area"); |
104 | 104 | |
105 | 105 | columnSingleton()->setColumn($this->index, $data); |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | $data = new ColumnModel(); |
115 | 115 | $data = $this->setDefaultModelValue($data); |
116 | 116 | $data->setLabel($label); |
117 | - $data->setName($this->name($label,$name)); |
|
118 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
117 | + $data->setName($this->name($label, $name)); |
|
118 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
119 | 119 | $data->setType("select"); |
120 | 120 | |
121 | 121 | columnSingleton()->setColumn($this->index, $data); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | private function name($label, $name = null) |
20 | 20 | { |
21 | - return (!$name)?strtolower(Str::slug($label,'_')):$name; |
|
21 | + return (!$name) ?strtolower(Str::slug($label, '_')) : $name; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | public function getIndexColumns() |
39 | 39 | { |
40 | 40 | $data = $this->columns; |
41 | - foreach($data as $i=>$item) { |
|
41 | + foreach ($data as $i=>$item) { |
|
42 | 42 | /** @var ColumnModel $item */ |
43 | - if($item->getShowIndex() === false) { |
|
43 | + if ($item->getShowIndex() === false) { |
|
44 | 44 | unset($data[$i]); |
45 | 45 | } |
46 | 46 | } |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | public function getAddEditColumns() |
51 | 51 | { |
52 | 52 | $data = $this->columns; |
53 | - foreach($data as $i=>$item) { |
|
53 | + foreach ($data as $i=>$item) { |
|
54 | 54 | /** @var ColumnModel $item */ |
55 | - if($item->getShowIndex() === false) { |
|
55 | + if ($item->getShowIndex() === false) { |
|
56 | 56 | unset($data[$i]); |
57 | 57 | } |
58 | 58 | |
59 | - if($item->getShowDetail() === false) { |
|
59 | + if ($item->getShowDetail() === false) { |
|
60 | 60 | unset($data[$i]); |
61 | 61 | } |
62 | 62 | |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | public function getEditColumns() |
68 | 68 | { |
69 | 69 | $data = $this->columns; |
70 | - foreach($data as $i=>$item) { |
|
70 | + foreach ($data as $i=>$item) { |
|
71 | 71 | /** @var ColumnModel $item */ |
72 | - if($item->getShowEdit() === false) { |
|
72 | + if ($item->getShowEdit() === false) { |
|
73 | 73 | unset($data[$i]); |
74 | 74 | } |
75 | 75 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | public function getAddColumns() |
80 | 80 | { |
81 | 81 | $data = $this->columns; |
82 | - foreach($data as $i=>$item) { |
|
82 | + foreach ($data as $i=>$item) { |
|
83 | 83 | /** @var ColumnModel $item */ |
84 | - if($item->getShowAdd() === false) { |
|
84 | + if ($item->getShowAdd() === false) { |
|
85 | 85 | unset($data[$i]); |
86 | 86 | } |
87 | 87 | } |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | public function getDetailColumns() |
92 | 92 | { |
93 | 93 | $data = $this->columns; |
94 | - foreach($data as $i=>$item) { |
|
94 | + foreach ($data as $i=>$item) { |
|
95 | 95 | /** @var ColumnModel $item */ |
96 | - if($item->getShowDetail() === false) { |
|
96 | + if ($item->getShowDetail() === false) { |
|
97 | 97 | unset($data[$i]); |
98 | 98 | } |
99 | 99 | } |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | public function getAssignmentData() |
104 | 104 | { |
105 | 105 | $data = []; |
106 | - foreach($this->columns as $column) { |
|
106 | + foreach ($this->columns as $column) { |
|
107 | 107 | /** @var ColumnModel $column */ |
108 | - if(is_array($column->getValue())) { |
|
109 | - foreach($column->getValue() as $key=>$val) { |
|
108 | + if (is_array($column->getValue())) { |
|
109 | + foreach ($column->getValue() as $key=>$val) { |
|
110 | 110 | $data[$key] = $val; |
111 | 111 | } |
112 | - }else{ |
|
112 | + } else { |
|
113 | 113 | $data[$column->getField()] = $column->getValue(); |
114 | 114 | } |
115 | 115 | } |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | public function removeColumn($label_or_name) |
120 | 120 | { |
121 | 121 | $data = $this->getColumns(); |
122 | - foreach($data as $i=>$d) |
|
122 | + foreach ($data as $i=>$d) |
|
123 | 123 | { |
124 | 124 | /** @var ColumnModel $d */ |
125 | - if($d->getLabel() == $label_or_name || $d->getName() == $label_or_name) { |
|
125 | + if ($d->getLabel() == $label_or_name || $d->getName() == $label_or_name) { |
|
126 | 126 | unset($data[$i]); |
127 | 127 | } |
128 | 128 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | public function getColumnNameOnly() |
133 | 133 | { |
134 | 134 | $result = []; |
135 | - foreach($this->columns as $column) { |
|
135 | + foreach ($this->columns as $column) { |
|
136 | 136 | /** @var ColumnModel $column */ |
137 | 137 | $result[] = $column->getName(); |
138 | 138 | } |
@@ -109,7 +109,7 @@ |
||
109 | 109 | foreach($column->getValue() as $key=>$val) { |
110 | 110 | $data[$key] = $val; |
111 | 111 | } |
112 | - }else{ |
|
112 | + } else{ |
|
113 | 113 | $data[$column->getField()] = $column->getValue(); |
114 | 114 | } |
115 | 115 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | |
30 | 30 | public function __call($method, $parameters) |
31 | 31 | { |
32 | - if($method == "getData") { |
|
32 | + if ($method == "getData") { |
|
33 | 33 | $key = $parameters[0]; |
34 | 34 | return $this->data[$key]; |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | } |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | |
48 | 48 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
49 | 49 | |
50 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
50 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
51 | 51 | { |
52 | 52 | $query = call_user_func($this->data['hook_query_index'], $query); |
53 | 53 | } |
54 | 54 | |
55 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
56 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
55 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
56 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
57 | 57 | $query->whereNull($this->data['table'].'.deleted_at'); |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | - if(isset($joins)) { |
|
62 | - foreach($joins as $join) |
|
61 | + if (isset($joins)) { |
|
62 | + foreach ($joins as $join) |
|
63 | 63 | { |
64 | 64 | $query->join($join['target_table'], |
65 | 65 | $join['target_table_primary'], |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - if(request()->has('q')) |
|
72 | + if (request()->has('q')) |
|
73 | 73 | { |
74 | - if(isset($this->data['hook_search_query'])) { |
|
74 | + if (isset($this->data['hook_search_query'])) { |
|
75 | 75 | $query = call_user_func($this->data['hook_search_query'], $query); |
76 | - }else{ |
|
77 | - $query->where(function ($where) use ($columns) { |
|
76 | + } else { |
|
77 | + $query->where(function($where) use ($columns) { |
|
78 | 78 | /** |
79 | 79 | * @var $where Builder |
80 | 80 | */ |
81 | - foreach($columns as $column) |
|
81 | + foreach ($columns as $column) |
|
82 | 82 | { |
83 | 83 | $where->orWhere($column['name'], 'like', '%'.request('q').'%'); |
84 | 84 | } |
@@ -86,17 +86,17 @@ discard block |
||
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
89 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
90 | 90 | $query = call_user_func($this->data['hook_query_index'], $query); |
91 | 91 | } |
92 | 92 | |
93 | 93 | |
94 | - if(request()->has(['order_by','order_sort'])) |
|
94 | + if (request()->has(['order_by', 'order_sort'])) |
|
95 | 95 | { |
96 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
96 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
97 | 97 | $query->orderBy(request('order_by'), request('order_sort')); |
98 | 98 | } |
99 | - }else{ |
|
99 | + } else { |
|
100 | 100 | $query->orderBy($this->data['order_by'][0], $this->data['order_by'][1]); |
101 | 101 | } |
102 | 102 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | public function getIndex() |
107 | 107 | { |
108 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
108 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
109 | 109 | |
110 | 110 | $query = $this->repository(); |
111 | 111 | $result = $query->paginate(20); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | if ($validator->fails()) { |
124 | 124 | $message = $validator->messages(); |
125 | 125 | $message_all = $message->all(); |
126 | - throw new CBValidationException(implode(', ',$message_all)); |
|
126 | + throw new CBValidationException(implode(', ', $message_all)); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | /** @var ColumnModel $column */ |
134 | 134 | $value = request($column->getName()); |
135 | 135 | |
136 | - if (! $column->getName()) { |
|
136 | + if (!$column->getName()) { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | 139 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | public function getAdd() |
146 | 146 | { |
147 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
147 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
148 | 148 | |
149 | 149 | $data = []; |
150 | 150 | $data['page_title'] = $this->data['page_title'].' : Add'; |
@@ -155,29 +155,29 @@ discard block |
||
155 | 155 | |
156 | 156 | public function postAddSave() |
157 | 157 | { |
158 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
158 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
159 | 159 | |
160 | 160 | try { |
161 | 161 | $this->validation(); |
162 | 162 | $this->assignment(); |
163 | 163 | $data = columnSingleton()->getAssignmentData(); |
164 | 164 | |
165 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
165 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
166 | 166 | $data['created_at'] = date('Y-m-d H:i:s'); |
167 | 167 | } |
168 | 168 | |
169 | 169 | $id = DB::table($this->data['table'])->insertGetId($data); |
170 | 170 | |
171 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
171 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
172 | 172 | call_user_func($this->data['hook_after_insert'], $id); |
173 | 173 | } |
174 | 174 | |
175 | 175 | } catch (CBValidationException $e) { |
176 | 176 | Log::debug($e); |
177 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
177 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
178 | 178 | } catch (\Exception $e) { |
179 | 179 | Log::error($e); |
180 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
180 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | if (request('submit') == trans('crudbooster.button_save_more')) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | public function getEdit($id) |
191 | 191 | { |
192 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
192 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
193 | 193 | |
194 | 194 | $data = []; |
195 | 195 | $data['row'] = $this->repository()->where(getPrimaryKey($this->data['table']), $id)->first(); |
@@ -201,17 +201,17 @@ discard block |
||
201 | 201 | |
202 | 202 | public function postEditSave($id) |
203 | 203 | { |
204 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
204 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
205 | 205 | |
206 | 206 | try { |
207 | 207 | $this->validation(); |
208 | 208 | $this->assignment(); |
209 | 209 | $data = columnSingleton()->getAssignmentData(); |
210 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
210 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
211 | 211 | $data['updated_at'] = date('Y-m-d H:i:s'); |
212 | 212 | } |
213 | 213 | |
214 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
214 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
215 | 215 | call_user_func($this->data['hook_before_update'], $id); |
216 | 216 | } |
217 | 217 | |
@@ -219,16 +219,16 @@ discard block |
||
219 | 219 | ->where(cb()->pk($this->data['table']), $id) |
220 | 220 | ->update($data); |
221 | 221 | |
222 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
222 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
223 | 223 | call_user_func($this->data['hook_after_update'], $id); |
224 | 224 | } |
225 | 225 | |
226 | 226 | } catch (CBValidationException $e) { |
227 | 227 | Log::debug($e); |
228 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
228 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
229 | 229 | } catch (\Exception $e) { |
230 | 230 | Log::error($e); |
231 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
231 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -241,15 +241,15 @@ discard block |
||
241 | 241 | |
242 | 242 | public function getDelete($id) |
243 | 243 | { |
244 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
244 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
245 | 245 | |
246 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
246 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
247 | 247 | call_user_func($this->data['hook_before_delete'], $id); |
248 | 248 | } |
249 | 249 | |
250 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
250 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
251 | 251 | |
252 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
252 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
253 | 253 | DB::table($this->data['table']) |
254 | 254 | ->where(getPrimaryKey($this->data['table']), $id) |
255 | 255 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | ->delete(); |
260 | 260 | } |
261 | 261 | |
262 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
262 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
263 | 263 | call_user_func($this->data['hook_after_delete'], $id); |
264 | 264 | } |
265 | 265 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | |
269 | 269 | public function getDetail($id) |
270 | 270 | { |
271 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
271 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area"); |
|
272 | 272 | |
273 | 273 | $data = []; |
274 | 274 | $data['row'] = $this->repository()->where(getPrimaryKey($this->data['table']), $id)->first(); |
@@ -279,21 +279,21 @@ discard block |
||
279 | 279 | |
280 | 280 | public function postUploadFile() |
281 | 281 | { |
282 | - if(auth()->guest()) return redirect(getAdminLoginURL()); |
|
282 | + if (auth()->guest()) return redirect(getAdminLoginURL()); |
|
283 | 283 | |
284 | 284 | $file = null; |
285 | 285 | try { |
286 | 286 | |
287 | 287 | cb()->validation([ |
288 | - 'userfile' => 'required|mimes:' . config('crudbooster.UPLOAD_TYPES') |
|
288 | + 'userfile' => 'required|mimes:'.config('crudbooster.UPLOAD_TYPES') |
|
289 | 289 | ]); |
290 | 290 | |
291 | 291 | $file = cb()->uploadFile('userfile', true); |
292 | 292 | |
293 | 293 | } catch (CBValidationException $e) { |
294 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
294 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
295 | 295 | } catch (\Exception $e) { |
296 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
296 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | return response()->json([ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | if($method == "getData") { |
33 | 33 | $key = $parameters[0]; |
34 | 34 | return $this->data[$key]; |
35 | - }else{ |
|
35 | + } else{ |
|
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | if(isset($this->data['hook_search_query'])) { |
75 | 75 | $query = call_user_func($this->data['hook_search_query'], $query); |
76 | - }else{ |
|
76 | + } else{ |
|
77 | 77 | $query->where(function ($where) use ($columns) { |
78 | 78 | /** |
79 | 79 | * @var $where Builder |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
97 | 97 | $query->orderBy(request('order_by'), request('order_sort')); |
98 | 98 | } |
99 | - }else{ |
|
99 | + } else{ |
|
100 | 100 | $query->orderBy($this->data['order_by'][0], $this->data['order_by'][1]); |
101 | 101 | } |
102 | 102 | |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | |
106 | 106 | public function getIndex() |
107 | 107 | { |
108 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
108 | + if(!module()->canBrowse()) { |
|
109 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
110 | + } |
|
109 | 111 | |
110 | 112 | $query = $this->repository(); |
111 | 113 | $result = $query->paginate(20); |
@@ -144,7 +146,9 @@ discard block |
||
144 | 146 | |
145 | 147 | public function getAdd() |
146 | 148 | { |
147 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
149 | + if(!module()->canCreate()) { |
|
150 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
151 | + } |
|
148 | 152 | |
149 | 153 | $data = []; |
150 | 154 | $data['page_title'] = $this->data['page_title'].' : Add'; |
@@ -155,7 +159,9 @@ discard block |
||
155 | 159 | |
156 | 160 | public function postAddSave() |
157 | 161 | { |
158 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
162 | + if(!module()->canCreate()) { |
|
163 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
164 | + } |
|
159 | 165 | |
160 | 166 | try { |
161 | 167 | $this->validation(); |
@@ -189,7 +195,9 @@ discard block |
||
189 | 195 | |
190 | 196 | public function getEdit($id) |
191 | 197 | { |
192 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
198 | + if(!module()->canUpdate()) { |
|
199 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
200 | + } |
|
193 | 201 | |
194 | 202 | $data = []; |
195 | 203 | $data['row'] = $this->repository()->where(getPrimaryKey($this->data['table']), $id)->first(); |
@@ -201,7 +209,9 @@ discard block |
||
201 | 209 | |
202 | 210 | public function postEditSave($id) |
203 | 211 | { |
204 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
212 | + if(!module()->canUpdate()) { |
|
213 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
214 | + } |
|
205 | 215 | |
206 | 216 | try { |
207 | 217 | $this->validation(); |
@@ -241,7 +251,9 @@ discard block |
||
241 | 251 | |
242 | 252 | public function getDelete($id) |
243 | 253 | { |
244 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
254 | + if(!module()->canDelete()) { |
|
255 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
256 | + } |
|
245 | 257 | |
246 | 258 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
247 | 259 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -268,7 +280,9 @@ discard block |
||
268 | 280 | |
269 | 281 | public function getDetail($id) |
270 | 282 | { |
271 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
283 | + if(!module()->canRead()) { |
|
284 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
285 | + } |
|
272 | 286 | |
273 | 287 | $data = []; |
274 | 288 | $data['row'] = $this->repository()->where(getPrimaryKey($this->data['table']), $id)->first(); |
@@ -279,7 +293,9 @@ discard block |
||
279 | 293 | |
280 | 294 | public function postUploadFile() |
281 | 295 | { |
282 | - if(auth()->guest()) return redirect(getAdminLoginURL()); |
|
296 | + if(auth()->guest()) { |
|
297 | + return redirect(getAdminLoginURL()); |
|
298 | + } |
|
283 | 299 | |
284 | 300 | $file = null; |
285 | 301 | try { |