@@ -51,7 +51,7 @@ |
||
51 | 51 | if (Request::is(cbConfig('ADMIN_PATH'))) { |
52 | 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 | } |
@@ -1,39 +1,39 @@ 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'=>"developer/".getSetting('developer_path'), |
6 | - 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
6 | + 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
7 | 7 | cb()->routeController("modules", "\crocodicstudio\crudbooster\controllers\DeveloperModulesController"); |
8 | 8 | cb()->routeController("menus", "\crocodicstudio\crudbooster\controllers\DeveloperMenusController"); |
9 | - cb()->routeController("roles","\crocodicstudio\crudbooster\controllers\DeveloperRolesController"); |
|
10 | - cb()->routeController("users","\crocodicstudio\crudbooster\controllers\DeveloperUsersController"); |
|
11 | - cb()->routeGet("/","DeveloperDashboardController@getIndex"); |
|
9 | + cb()->routeController("roles", "\crocodicstudio\crudbooster\controllers\DeveloperRolesController"); |
|
10 | + cb()->routeController("users", "\crocodicstudio\crudbooster\controllers\DeveloperUsersController"); |
|
11 | + cb()->routeGet("/", "DeveloperDashboardController@getIndex"); |
|
12 | 12 | }); |
13 | 13 | |
14 | 14 | // Developer Auth Middleware |
15 | 15 | Route::group(['middleware' => ['web'], |
16 | 16 | 'prefix'=>"developer/".getSetting('developer_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"); |
33 | 33 | }); |
34 | 34 | |
35 | 35 | // Routing package controllers |
36 | -cb()->routeGroupBackend(function () { |
|
36 | +cb()->routeGroupBackend(function() { |
|
37 | 37 | cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController'); |
38 | 38 | }); |
39 | 39 | |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | 'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class], |
43 | 43 | 'prefix' => cbConfig('ADMIN_PATH'), |
44 | 44 | 'namespace' => 'App\Http\Controllers', |
45 | -], function () { |
|
45 | +], function() { |
|
46 | 46 | |
47 | 47 | if (Request::is(cbConfig('ADMIN_PATH'))) { |
48 | - if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
|
48 | + if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
|
49 | 49 | cb()->routeGet("/", $dashboard); |
50 | - }else{ |
|
50 | + } else { |
|
51 | 51 | cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | 55 | $controllers = glob(app_path('Http/Controllers/Admin*Controller.php')); |
56 | 56 | |
57 | - foreach($controllers as $controller) { |
|
57 | + foreach ($controllers as $controller) { |
|
58 | 58 | $controllerName = basename($controller); |
59 | - $controllerName = rtrim($controllerName,".php"); |
|
59 | + $controllerName = rtrim($controllerName, ".php"); |
|
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 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | @endforeach |
11 | 11 | |
12 | 12 | <?php |
13 | - if(cb()->getCurrentMethod()=="getEdit") { |
|
13 | + if (cb()->getCurrentMethod() == "getEdit") { |
|
14 | 14 | /** @var $row object */ |
15 | 15 | columnSingleton()->valueAssignment($row); |
16 | 16 | } |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | public function getIndex() { |
28 | 28 | $data = []; |
29 | 29 | $data['result'] = DB::table("users") |
30 | - ->join("cb_roles","cb_roles.id","=","cb_roles_id") |
|
31 | - ->select("users.*","cb_roles.name as cb_roles_name") |
|
30 | + ->join("cb_roles", "cb_roles.id", "=", "cb_roles_id") |
|
31 | + ->select("users.*", "cb_roles.name as cb_roles_name") |
|
32 | 32 | ->get(); |
33 | - return view($this->view.'.index',$data); |
|
33 | + return view($this->view.'.index', $data); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function getAdd() { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public function postAddSave() { |
43 | 43 | try { |
44 | - cb()->validation(['name', 'email','password','cb_roles_id']); |
|
44 | + cb()->validation(['name', 'email', 'password', 'cb_roles_id']); |
|
45 | 45 | |
46 | 46 | $user = []; |
47 | 47 | $user['name'] = request('name'); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $user['cb_roles_id'] = request('cb_roles_id'); |
51 | 51 | DB::table('users')->insert($user); |
52 | 52 | |
53 | - return cb()->redirect(route("DeveloperUsersControllerGetIndex"),"New user has been created!","success"); |
|
53 | + return cb()->redirect(route("DeveloperUsersControllerGetIndex"), "New user has been created!", "success"); |
|
54 | 54 | |
55 | 55 | } catch (CBValidationException $e) { |
56 | 56 | return cb()->redirectBack($e->getMessage()); |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | |
67 | 67 | public function postEditSave($id) { |
68 | 68 | try { |
69 | - cb()->validation(['name', 'email','cb_roles_id']); |
|
69 | + cb()->validation(['name', 'email', 'cb_roles_id']); |
|
70 | 70 | |
71 | 71 | $user = []; |
72 | 72 | $user['name'] = request('name'); |
73 | 73 | $user['email'] = request('email'); |
74 | - if(request('password')) $user['password'] = Hash::make(request('password')); |
|
74 | + if (request('password')) $user['password'] = Hash::make(request('password')); |
|
75 | 75 | $user['cb_roles_id'] = request('cb_roles_id'); |
76 | - DB::table('users')->where('id',$id)->update($user); |
|
76 | + DB::table('users')->where('id', $id)->update($user); |
|
77 | 77 | |
78 | - return cb()->redirect(route("DeveloperUsersControllerGetIndex"),"The user has been updated!","success"); |
|
78 | + return cb()->redirect(route("DeveloperUsersControllerGetIndex"), "The user has been updated!", "success"); |
|
79 | 79 | |
80 | 80 | } catch (CBValidationException $e) { |
81 | 81 | return cb()->redirectBack($e->getMessage()); |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | public function getDelete($id) { |
86 | - DB::table("users")->where("id",$id)->delete(); |
|
87 | - return cb()->redirectBack("The user has been deleted!","success"); |
|
86 | + DB::table("users")->where("id", $id)->delete(); |
|
87 | + return cb()->redirectBack("The user has been deleted!", "success"); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -71,7 +71,9 @@ |
||
71 | 71 | $user = []; |
72 | 72 | $user['name'] = request('name'); |
73 | 73 | $user['email'] = request('email'); |
74 | - if(request('password')) $user['password'] = Hash::make(request('password')); |
|
74 | + if(request('password')) { |
|
75 | + $user['password'] = Hash::make(request('password')); |
|
76 | + } |
|
75 | 77 | $user['cb_roles_id'] = request('cb_roles_id'); |
76 | 78 | DB::table('users')->where('id',$id)->update($user); |
77 | 79 |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | $menu['type'] = request('type'); |
55 | 55 | if(request('type') == 'module') { |
56 | 56 | $menu['cb_modules_id'] = request('cb_modules_id'); |
57 | - }elseif (request('type') == 'url') { |
|
57 | + } elseif (request('type') == 'url') { |
|
58 | 58 | $menu['path'] = request('url_value'); |
59 | - }elseif (request('type') == 'path') { |
|
59 | + } elseif (request('type') == 'path') { |
|
60 | 60 | $menu['path'] = request('path_value'); |
61 | 61 | } |
62 | 62 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | $menu['type'] = request('type'); |
80 | 80 | if(request('type') == 'module') { |
81 | 81 | $menu['cb_modules_id'] = request('cb_modules_id'); |
82 | - }elseif (request('type') == 'url') { |
|
82 | + } elseif (request('type') == 'url') { |
|
83 | 83 | $menu['path'] = request('url_value'); |
84 | - }elseif (request('type') == 'path') { |
|
84 | + } elseif (request('type') == 'path') { |
|
85 | 85 | $menu['path'] = request('path_value'); |
86 | 86 | } |
87 | 87 | DB::table("cb_menus")->where("id",$id)->update($menu); |
@@ -24,22 +24,22 @@ discard block |
||
24 | 24 | |
25 | 25 | public function getIndex() { |
26 | 26 | $data = []; |
27 | - return view($this->view.".index",$data); |
|
27 | + return view($this->view.".index", $data); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getAdd() { |
31 | 31 | $data = []; |
32 | 32 | $data['form_title'] = "Add Menu"; |
33 | 33 | $data['form_url'] = route('DeveloperMenusControllerPostAddSave'); |
34 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
34 | + $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get(); |
|
35 | 35 | return view($this->view.".form", $data); |
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getEdit($id) { |
39 | 39 | $data = []; |
40 | 40 | $data['form_title'] = "Edit Menu"; |
41 | - $data['form_url'] = route('DeveloperMenusControllerPostEditSave',['id'=>$id]); |
|
42 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
41 | + $data['form_url'] = route('DeveloperMenusControllerPostEditSave', ['id'=>$id]); |
|
42 | + $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get(); |
|
43 | 43 | $data['row'] = cb()->find("cb_menus", $id); |
44 | 44 | return view($this->view.".form", $data); |
45 | 45 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $menu['name'] = request('name'); |
53 | 53 | $menu['icon'] = request('icon'); |
54 | 54 | $menu['type'] = request('type'); |
55 | - if(request('type') == 'module') { |
|
55 | + if (request('type') == 'module') { |
|
56 | 56 | $menu['cb_modules_id'] = request('cb_modules_id'); |
57 | 57 | }elseif (request('type') == 'url') { |
58 | 58 | $menu['path'] = request('url_value'); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | DB::table("cb_menus")->insert($menu); |
64 | 64 | |
65 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been added!","success"); |
|
65 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been added!", "success"); |
|
66 | 66 | |
67 | 67 | } catch (CBValidationException $e) { |
68 | 68 | return cb()->redirectBack($e->getMessage()); |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | $menu['name'] = request('name'); |
78 | 78 | $menu['icon'] = request('icon'); |
79 | 79 | $menu['type'] = request('type'); |
80 | - if(request('type') == 'module') { |
|
80 | + if (request('type') == 'module') { |
|
81 | 81 | $menu['cb_modules_id'] = request('cb_modules_id'); |
82 | 82 | }elseif (request('type') == 'url') { |
83 | 83 | $menu['path'] = request('url_value'); |
84 | 84 | }elseif (request('type') == 'path') { |
85 | 85 | $menu['path'] = request('path_value'); |
86 | 86 | } |
87 | - DB::table("cb_menus")->where("id",$id)->update($menu); |
|
87 | + DB::table("cb_menus")->where("id", $id)->update($menu); |
|
88 | 88 | |
89 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been saved!","success"); |
|
89 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been saved!", "success"); |
|
90 | 90 | |
91 | 91 | } catch (CBValidationException $e) { |
92 | 92 | return cb()->redirectBack($e->getMessage()); |
@@ -99,20 +99,20 @@ discard block |
||
99 | 99 | |
100 | 100 | $menus = request('menus'); |
101 | 101 | $menus = json_decode($menus, true); |
102 | - if($menus) { |
|
102 | + if ($menus) { |
|
103 | 103 | $menus = $menus[0]; |
104 | - if($menus) { |
|
105 | - foreach($menus as $i=>$menu) { |
|
104 | + if ($menus) { |
|
105 | + foreach ($menus as $i=>$menu) { |
|
106 | 106 | $id = $menu['id']; |
107 | - cb()->update("cb_menus",$id,["sort_number"=>$i,'parent_cb_menus_id'=>null]); |
|
108 | - if($menu['children'][0]) { |
|
109 | - foreach($menu['children'][0] as $ii=>$sub) { |
|
107 | + cb()->update("cb_menus", $id, ["sort_number"=>$i, 'parent_cb_menus_id'=>null]); |
|
108 | + if ($menu['children'][0]) { |
|
109 | + foreach ($menu['children'][0] as $ii=>$sub) { |
|
110 | 110 | $id = $sub['id']; |
111 | - cb()->update("cb_menus",$id,["sort_number"=>$ii,"parent_cb_menus_id"=>$menu['id']]); |
|
112 | - if($sub['children'][0]) { |
|
113 | - foreach($sub['children'][0] as $iii=>$subsub) { |
|
111 | + cb()->update("cb_menus", $id, ["sort_number"=>$ii, "parent_cb_menus_id"=>$menu['id']]); |
|
112 | + if ($sub['children'][0]) { |
|
113 | + foreach ($sub['children'][0] as $iii=>$subsub) { |
|
114 | 114 | $id = $subsub['id']; |
115 | - cb()->update("cb_menus",$id,["sort_number"=>$iii,"parent_cb_menus_id"=>$sub['id']]); |
|
115 | + cb()->update("cb_menus", $id, ["sort_number"=>$iii, "parent_cb_menus_id"=>$sub['id']]); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
@@ -121,17 +121,17 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - return response()->json(['api_status'=>1,'api_message'=>'success']); |
|
124 | + return response()->json(['api_status'=>1, 'api_message'=>'success']); |
|
125 | 125 | |
126 | 126 | } catch (CBValidationException $e) { |
127 | - return response()->json(['api_status'=>0,'api_message'=>$e->getMessage()]); |
|
127 | + return response()->json(['api_status'=>0, 'api_message'=>$e->getMessage()]); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | 131 | public function getDelete($id) { |
132 | - DB::table("cb_menus")->where("id",$id)->delete(); |
|
132 | + DB::table("cb_menus")->where("id", $id)->delete(); |
|
133 | 133 | |
134 | - return cb()->redirectBack("The menu has been deleted!","success"); |
|
134 | + return cb()->redirectBack("The menu has been deleted!", "success"); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | } |
138 | 138 | \ No newline at end of file |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public function getIndex() { |
16 | 16 | $data = []; |
17 | 17 | $data['page_title'] = "Dashboard"; |
18 | - return view('crudbooster::dev_layouts.modules.dashboard',$data); |
|
18 | + return view('crudbooster::dev_layouts.modules.dashboard', $data); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 |
@@ -76,45 +76,60 @@ discard block |
||
76 | 76 | |
77 | 77 | public function canBrowse() { |
78 | 78 | if($this->privilege) { |
79 | - if($this->privilege->can_browse) return true; |
|
80 | - else return false; |
|
81 | - }else{ |
|
79 | + if($this->privilege->can_browse) { |
|
80 | + return true; |
|
81 | + } else { |
|
82 | + return false; |
|
83 | + } |
|
84 | + } else{ |
|
82 | 85 | return true; |
83 | 86 | } |
84 | 87 | } |
85 | 88 | |
86 | 89 | public function canCreate() { |
87 | 90 | if($this->privilege) { |
88 | - if($this->privilege->can_create) return true; |
|
89 | - else return false; |
|
90 | - }else{ |
|
91 | + if($this->privilege->can_create) { |
|
92 | + return true; |
|
93 | + } else { |
|
94 | + return false; |
|
95 | + } |
|
96 | + } else{ |
|
91 | 97 | return true; |
92 | 98 | } |
93 | 99 | } |
94 | 100 | |
95 | 101 | public function canRead() { |
96 | 102 | if($this->privilege) { |
97 | - if($this->privilege->can_read) return true; |
|
98 | - else return false; |
|
99 | - }else{ |
|
103 | + if($this->privilege->can_read) { |
|
104 | + return true; |
|
105 | + } else { |
|
106 | + return false; |
|
107 | + } |
|
108 | + } else{ |
|
100 | 109 | return true; |
101 | 110 | } |
102 | 111 | } |
103 | 112 | |
104 | 113 | public function canUpdate() { |
105 | 114 | if($this->privilege) { |
106 | - if($this->privilege->can_update) return true; |
|
107 | - else return false; |
|
108 | - }else{ |
|
115 | + if($this->privilege->can_update) { |
|
116 | + return true; |
|
117 | + } else { |
|
118 | + return false; |
|
119 | + } |
|
120 | + } else{ |
|
109 | 121 | return true; |
110 | 122 | } |
111 | 123 | } |
112 | 124 | |
113 | 125 | public function canDelete() { |
114 | 126 | if($this->privilege) { |
115 | - if($this->privilege->can_delete) return true; |
|
116 | - else return false; |
|
117 | - }else{ |
|
127 | + if($this->privilege->can_delete) { |
|
128 | + return true; |
|
129 | + } else { |
|
130 | + return false; |
|
131 | + } |
|
132 | + } else{ |
|
118 | 133 | return true; |
119 | 134 | } |
120 | 135 | } |
@@ -123,7 +138,7 @@ discard block |
||
123 | 138 | { |
124 | 139 | if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
125 | 140 | return action($this->controller.'@getAdd'); |
126 | - }else{ |
|
141 | + } else{ |
|
127 | 142 | return null; |
128 | 143 | } |
129 | 144 | } |
@@ -132,7 +147,7 @@ discard block |
||
132 | 147 | { |
133 | 148 | if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
134 | 149 | return action($this->controller.'@postAddSave'); |
135 | - }else{ |
|
150 | + } else{ |
|
136 | 151 | return null; |
137 | 152 | } |
138 | 153 | } |
@@ -141,7 +156,7 @@ discard block |
||
141 | 156 | { |
142 | 157 | if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
143 | 158 | return action($this->controller.'@getEdit',['id'=>$id]); |
144 | - }else{ |
|
159 | + } else{ |
|
145 | 160 | return null; |
146 | 161 | } |
147 | 162 | } |
@@ -150,7 +165,7 @@ discard block |
||
150 | 165 | { |
151 | 166 | if(method_exists($this->controller_class, 'postEditSave')) { |
152 | 167 | return action($this->controller.'@postEditSave',['id'=>$id]); |
153 | - }else{ |
|
168 | + } else{ |
|
154 | 169 | return null; |
155 | 170 | } |
156 | 171 | } |
@@ -159,7 +174,7 @@ discard block |
||
159 | 174 | { |
160 | 175 | if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
161 | 176 | return action($this->controller.'@getDetail',['id'=>$id]); |
162 | - }else{ |
|
177 | + } else{ |
|
163 | 178 | return null; |
164 | 179 | } |
165 | 180 | } |
@@ -168,7 +183,7 @@ discard block |
||
168 | 183 | { |
169 | 184 | if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
170 | 185 | return action($this->controller.'@getDelete',['id'=>$id]); |
171 | - }else{ |
|
186 | + } else{ |
|
172 | 187 | return null; |
173 | 188 | } |
174 | 189 | } |
@@ -177,7 +192,7 @@ discard block |
||
177 | 192 | { |
178 | 193 | if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
179 | 194 | return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
180 | - }else{ |
|
195 | + } else{ |
|
181 | 196 | return null; |
182 | 197 | } |
183 | 198 | } |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | try { |
27 | 27 | $routeArray = request()->route()->getAction(); |
28 | 28 | $this->controller = class_basename($routeArray['controller']); |
29 | - $this->controller = strtok($this->controller,"@"); |
|
29 | + $this->controller = strtok($this->controller, "@"); |
|
30 | 30 | |
31 | 31 | $className = "\\".$routeArray["namespace"]."\\".$this->controller; |
32 | - if(class_exists($className)) { |
|
33 | - $this->module = cb()->find("cb_modules",["controller"=>$this->controller]); |
|
34 | - if($this->module) { |
|
32 | + if (class_exists($className)) { |
|
33 | + $this->module = cb()->find("cb_modules", ["controller"=>$this->controller]); |
|
34 | + if ($this->module) { |
|
35 | 35 | $this->controller_class = new $className(); |
36 | - $this->menu = cb()->find("cb_menus",["cb_modules_id"=>$this->module->id]); |
|
37 | - $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu; |
|
38 | - if($this->menu) { |
|
36 | + $this->menu = cb()->find("cb_menus", ["cb_modules_id"=>$this->module->id]); |
|
37 | + $this->menu = (!$this->menu) ?cb()->find("cb_menus", ["type"=>"path", "path"=>request()->segment(2)]) : $this->menu; |
|
38 | + if ($this->menu) { |
|
39 | 39 | $this->privilege = DB::table("cb_role_privileges") |
40 | 40 | ->where("cb_menus_id", $this->menu->id) |
41 | 41 | ->where("cb_roles_id", cb()->session()->roleId()) |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | public function getData($key) { |
60 | - if($this->controller_class) { |
|
60 | + if ($this->controller_class) { |
|
61 | 61 | $value = $this->controller_class->getData($key); |
62 | - if(isset($value)) { |
|
62 | + if (isset($value)) { |
|
63 | 63 | return $value; |
64 | 64 | } |
65 | 65 | } |
@@ -70,128 +70,128 @@ discard block |
||
70 | 70 | * @return CBController |
71 | 71 | */ |
72 | 72 | public function getController() { |
73 | - return ($this->controller_class)?$this->controller_class:null; |
|
73 | + return ($this->controller_class) ? $this->controller_class : null; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public function getPageTitle() |
77 | 77 | { |
78 | - return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null; |
|
78 | + return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function getTable() |
82 | 82 | { |
83 | - return ($this->controller_class)?$this->controller_class->getData("table"):null; |
|
83 | + return ($this->controller_class) ? $this->controller_class->getData("table") : null; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | public function getPageIcon() |
87 | 87 | { |
88 | - return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null; |
|
88 | + return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | public function canBrowse() { |
92 | - if($this->privilege) { |
|
93 | - if($this->privilege->can_browse) return true; |
|
92 | + if ($this->privilege) { |
|
93 | + if ($this->privilege->can_browse) return true; |
|
94 | 94 | else return false; |
95 | - }else{ |
|
95 | + } else { |
|
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | 100 | public function canCreate() { |
101 | - if($this->privilege) { |
|
102 | - if($this->privilege->can_create) return true; |
|
101 | + if ($this->privilege) { |
|
102 | + if ($this->privilege->can_create) return true; |
|
103 | 103 | else return false; |
104 | - }else{ |
|
104 | + } else { |
|
105 | 105 | return true; |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | 109 | public function canRead() { |
110 | - if($this->privilege) { |
|
111 | - if($this->privilege->can_read) return true; |
|
110 | + if ($this->privilege) { |
|
111 | + if ($this->privilege->can_read) return true; |
|
112 | 112 | else return false; |
113 | - }else{ |
|
113 | + } else { |
|
114 | 114 | return true; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | public function canUpdate() { |
119 | - if($this->privilege) { |
|
120 | - if($this->privilege->can_update) return true; |
|
119 | + if ($this->privilege) { |
|
120 | + if ($this->privilege->can_update) return true; |
|
121 | 121 | else return false; |
122 | - }else{ |
|
122 | + } else { |
|
123 | 123 | return true; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | 127 | public function canDelete() { |
128 | - if($this->privilege) { |
|
129 | - if($this->privilege->can_delete) return true; |
|
128 | + if ($this->privilege) { |
|
129 | + if ($this->privilege->can_delete) return true; |
|
130 | 130 | else return false; |
131 | - }else{ |
|
131 | + } else { |
|
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | 136 | public function addURL() |
137 | 137 | { |
138 | - if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
138 | + if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
139 | 139 | return action($this->controller.'@getAdd'); |
140 | - }else{ |
|
140 | + } else { |
|
141 | 141 | return null; |
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | public function addSaveURL() |
146 | 146 | { |
147 | - if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
147 | + if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
148 | 148 | return action($this->controller.'@postAddSave'); |
149 | - }else{ |
|
149 | + } else { |
|
150 | 150 | return null; |
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | 154 | public function editURL($id = null) |
155 | 155 | { |
156 | - if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
157 | - return action($this->controller.'@getEdit',['id'=>$id]); |
|
158 | - }else{ |
|
156 | + if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
157 | + return action($this->controller.'@getEdit', ['id'=>$id]); |
|
158 | + } else { |
|
159 | 159 | return null; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | public function editSaveURL($id = null) |
164 | 164 | { |
165 | - if(method_exists($this->controller_class, 'postEditSave')) { |
|
166 | - return action($this->controller.'@postEditSave',['id'=>$id]); |
|
167 | - }else{ |
|
165 | + if (method_exists($this->controller_class, 'postEditSave')) { |
|
166 | + return action($this->controller.'@postEditSave', ['id'=>$id]); |
|
167 | + } else { |
|
168 | 168 | return null; |
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | - public function detailURL($id=null) |
|
172 | + public function detailURL($id = null) |
|
173 | 173 | { |
174 | - if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
175 | - return action($this->controller.'@getDetail',['id'=>$id]); |
|
176 | - }else{ |
|
174 | + if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
175 | + return action($this->controller.'@getDetail', ['id'=>$id]); |
|
176 | + } else { |
|
177 | 177 | return null; |
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - public function deleteURL($id=null) |
|
181 | + public function deleteURL($id = null) |
|
182 | 182 | { |
183 | - if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
184 | - return action($this->controller.'@getDelete',['id'=>$id]); |
|
185 | - }else{ |
|
183 | + if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
184 | + return action($this->controller.'@getDelete', ['id'=>$id]); |
|
185 | + } else { |
|
186 | 186 | return null; |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | public function url($path = null) |
191 | 191 | { |
192 | - if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
193 | - return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
|
194 | - }else{ |
|
192 | + if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
193 | + return trim(action($this->controller.'@getIndex').'/'.$path, '/'); |
|
194 | + } else { |
|
195 | 195 | return null; |
196 | 196 | } |
197 | 197 | } |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | public function indexRender($row, $column) |
22 | 22 | { |
23 | - if($column->getFormat()) { |
|
23 | + if ($column->getFormat()) { |
|
24 | 24 | return date($column->getFormat(), strtotime($row->{$column->getField()})); |
25 | - }else{ |
|
25 | + } else { |
|
26 | 26 | return $row->{$column->getField()}; |
27 | 27 | } |
28 | 28 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | { |
23 | 23 | if($column->getFormat()) { |
24 | 24 | return date($column->getFormat(), strtotime($row->{$column->getField()})); |
25 | - }else{ |
|
25 | + } else{ |
|
26 | 26 | return $row->{$column->getField()}; |
27 | 27 | } |
28 | 28 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $data = DB::table($table); |
37 | 37 | if($SQLCondition && is_callable($SQLCondition)) { |
38 | 38 | $data = call_user_func($SQLCondition, $data); |
39 | - }elseif ($SQLCondition && is_string($SQLCondition)) { |
|
39 | + } elseif ($SQLCondition && is_string($SQLCondition)) { |
|
40 | 40 | $data->whereRaw($SQLCondition); |
41 | 41 | } |
42 | 42 | $data = $data->get(); |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
37 | 37 | |
38 | - if(strpos($table,"App\Models")!==false) { |
|
38 | + if (strpos($table, "App\Models") !== false) { |
|
39 | 39 | $table = new $table(); |
40 | 40 | $table = $table::$tableName; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $data = DB::table($table); |
44 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
44 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
45 | 45 | $data = call_user_func($SQLCondition, $data); |
46 | 46 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
47 | 47 | $data->whereRaw($SQLCondition); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $data = $data->get(); |
50 | 50 | $options = []; |
51 | 51 | foreach ($data as $d) { |
52 | - $options[ $d->$key_field ] = $d->$display_field; |
|
52 | + $options[$d->$key_field] = $d->$display_field; |
|
53 | 53 | } |
54 | 54 | $this->options($options); |
55 | 55 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('cb_menus', function (Blueprint $table) { |
|
15 | + Schema::create('cb_menus', function(Blueprint $table) { |
|
16 | 16 | $table->increments("id"); |
17 | 17 | $table->string('name'); |
18 | 18 | $table->string("icon")->nullable(); |