@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | * @param $SQLCondition string|callable |
41 | 41 | */ |
42 | 42 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
43 | - if(strpos($table,"App\Models")!==false) { |
|
43 | + if (strpos($table, "App\Models") !== false) { |
|
44 | 44 | $table = new $table(); |
45 | 45 | $table = $table::$tableName; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $data = DB::table($table); |
49 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
49 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
50 | 50 | $data = call_user_func($SQLCondition, $data); |
51 | 51 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
52 | 52 | $data->whereRaw($SQLCondition); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $data = $data->get(); |
55 | 55 | $options = []; |
56 | 56 | foreach ($data as $d) { |
57 | - $options[ $d->$key_field ] = $d->$display_field; |
|
57 | + $options[$d->$key_field] = $d->$display_field; |
|
58 | 58 | } |
59 | 59 | $this->options($options); |
60 | 60 | } |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | public function getIndex() { |
26 | 26 | $data = []; |
27 | 27 | $data['result'] = DB::table("cb_roles")->get(); |
28 | - return view($this->view.".index",$data); |
|
28 | + return view($this->view.".index", $data); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function getAdd() { |
32 | 32 | $data = []; |
33 | - $data['menus'] = DB::table("cb_menus")->orderBy("name","asc")->get(); |
|
33 | + $data['menus'] = DB::table("cb_menus")->orderBy("name", "asc")->get(); |
|
34 | 34 | return view($this->view.".add", $data); |
35 | 35 | } |
36 | 36 | |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | $privilege = []; |
50 | 50 | $privilege["cb_roles_id"] = $roles_id; |
51 | 51 | $privilege["cb_menus_id"] = $menus_id; |
52 | - $privilege["can_browse"] = @$access['can_browse']?:0; |
|
53 | - $privilege["can_create"] = @$access['can_create']?:0; |
|
54 | - $privilege["can_read"] = @$access['can_read']?:0; |
|
55 | - $privilege["can_update"] = @$access['can_update']?:0; |
|
56 | - $privilege["can_delete"] = @$access['can_delete']?:0; |
|
52 | + $privilege["can_browse"] = @$access['can_browse'] ?: 0; |
|
53 | + $privilege["can_create"] = @$access['can_create'] ?: 0; |
|
54 | + $privilege["can_read"] = @$access['can_read'] ?: 0; |
|
55 | + $privilege["can_update"] = @$access['can_update'] ?: 0; |
|
56 | + $privilege["can_delete"] = @$access['can_delete'] ?: 0; |
|
57 | 57 | DB::table("cb_role_privileges")->insert($privilege); |
58 | 58 | } |
59 | 59 | |
60 | 60 | DB::commit(); |
61 | 61 | |
62 | - return cb()->redirect(route("DeveloperRolesControllerGetIndex"),"The role has been saved!","success"); |
|
62 | + return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been saved!", "success"); |
|
63 | 63 | |
64 | 64 | } catch (CBValidationException $e) { |
65 | 65 | return cb()->redirectBack($e->getMessage()); |
@@ -74,21 +74,21 @@ discard block |
||
74 | 74 | $data['row'] = cb()->find("cb_roles", $id); |
75 | 75 | |
76 | 76 | $menus = DB::table("cb_menus") |
77 | - ->leftjoin("cb_role_privileges",function($join) use ($id) { |
|
78 | - $join->on("cb_role_privileges.cb_menus_id","=","cb_menus.id")->where("cb_role_privileges.cb_roles_id", $id); |
|
77 | + ->leftjoin("cb_role_privileges", function($join) use ($id) { |
|
78 | + $join->on("cb_role_privileges.cb_menus_id", "=", "cb_menus.id")->where("cb_role_privileges.cb_roles_id", $id); |
|
79 | 79 | }) |
80 | - ->orderBy("cb_menus.name","asc") |
|
81 | - ->select("cb_menus.*","can_browse","can_create","can_read","can_update","can_delete") |
|
80 | + ->orderBy("cb_menus.name", "asc") |
|
81 | + ->select("cb_menus.*", "can_browse", "can_create", "can_read", "can_update", "can_delete") |
|
82 | 82 | ->get(); |
83 | 83 | $data['menus'] = $menus; |
84 | 84 | |
85 | - return view($this->view.".edit",$data); |
|
85 | + return view($this->view.".edit", $data); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | private function existsPrivilege($cb_roles_id, $cb_menus_id) { |
89 | - if($row = cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id])) { |
|
89 | + if ($row = cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id])) { |
|
90 | 90 | return $row->id; |
91 | - }else{ |
|
91 | + } else { |
|
92 | 92 | return null; |
93 | 93 | } |
94 | 94 | } |
@@ -97,26 +97,26 @@ discard block |
||
97 | 97 | try { |
98 | 98 | cb()->validation(['name', 'menus']); |
99 | 99 | |
100 | - cb()->updateCompact("cb_roles",$id,['name']); |
|
100 | + cb()->updateCompact("cb_roles", $id, ['name']); |
|
101 | 101 | |
102 | 102 | foreach (request("menus") as $menus_id) { |
103 | 103 | @$access = request("access")[$menus_id]; |
104 | 104 | $privilege = []; |
105 | 105 | $privilege["cb_roles_id"] = $id; |
106 | 106 | $privilege["cb_menus_id"] = $menus_id; |
107 | - $privilege["can_browse"] = @$access['can_browse']?:0; |
|
108 | - $privilege["can_create"] = @$access['can_create']?:0; |
|
109 | - $privilege["can_read"] = @$access['can_read']?:0; |
|
110 | - $privilege["can_update"] = @$access['can_update']?:0; |
|
111 | - $privilege["can_delete"] = @$access['can_delete']?:0; |
|
112 | - if($privilege_id = $this->existsPrivilege($id, $menus_id)) { |
|
107 | + $privilege["can_browse"] = @$access['can_browse'] ?: 0; |
|
108 | + $privilege["can_create"] = @$access['can_create'] ?: 0; |
|
109 | + $privilege["can_read"] = @$access['can_read'] ?: 0; |
|
110 | + $privilege["can_update"] = @$access['can_update'] ?: 0; |
|
111 | + $privilege["can_delete"] = @$access['can_delete'] ?: 0; |
|
112 | + if ($privilege_id = $this->existsPrivilege($id, $menus_id)) { |
|
113 | 113 | DB::table("cb_role_privileges")->where("id", $privilege_id)->update($privilege); |
114 | - }else{ |
|
114 | + } else { |
|
115 | 115 | DB::table("cb_role_privileges")->insert($privilege); |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - return cb()->redirect(route("DeveloperRolesControllerGetIndex"),"The role has been saved!","success"); |
|
119 | + return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been saved!", "success"); |
|
120 | 120 | |
121 | 121 | } catch (CBValidationException $e) { |
122 | 122 | |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | |
127 | 127 | public function getDelete($id) { |
128 | 128 | DB::table("cb_roles")->where("id", $id)->delete(); |
129 | - DB::table("cb_role_privileges")->where("cb_roles_id",$id)->delete(); |
|
129 | + DB::table("cb_role_privileges")->where("cb_roles_id", $id)->delete(); |
|
130 | 130 | |
131 | - return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been deleted!","success"); |
|
131 | + return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been deleted!", "success"); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | } |
135 | 135 | \ No newline at end of file |
@@ -21,10 +21,10 @@ |
||
21 | 21 | public function options($data_options) { |
22 | 22 | $data = columnSingleton()->getColumn($this->index); |
23 | 23 | |
24 | - foreach($data_options as $key=>$option) { |
|
25 | - if(is_int($key)) { |
|
24 | + foreach ($data_options as $key=>$option) { |
|
25 | + if (is_int($key)) { |
|
26 | 26 | $data_options[$option] = $option; |
27 | - }else{ |
|
27 | + } else { |
|
28 | 28 | $data_options[$key] = $option; |
29 | 29 | } |
30 | 30 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | name="{{ $column->getName() }}" id="{{ $column->getName() }}"> |
8 | 8 | <option value="">** Select a {{ $column->getLabel() }}</option> |
9 | 9 | <?php |
10 | - $columnValue = old($column->getName())?:($column->getDefaultValue())?:$column->getValue(); |
|
10 | + $columnValue = old($column->getName()) ?: ($column->getDefaultValue()) ?: $column->getValue(); |
|
11 | 11 | ?> |
12 | 12 | @foreach($column->getOptions() as $key=>$value) |
13 | 13 | <option {{ $columnValue==$key?'selected':'' }} value="{{ $key }}">{{ $value }}</option> |
@@ -21,7 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | $option = $column->getOptions(); |
23 | 23 | $key = $row->{ $column->getField() }; |
24 | - return @$option[ $key ]; |
|
24 | + return @$option[$key]; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function detailRender($row, $column) |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -cb()->routeGroupBackend(function () { |
|
4 | - cb()->routePost("select-table-lookup",'\crocodicstudio\crudbooster\types\select_table\SelectTableController@postLookup'); |
|
3 | +cb()->routeGroupBackend(function() { |
|
4 | + cb()->routePost("select-table-lookup", '\crocodicstudio\crudbooster\types\select_table\SelectTableController@postLookup'); |
|
5 | 5 | }); |
6 | 6 | \ No newline at end of file |
@@ -8,7 +8,7 @@ |
||
8 | 8 | <option value="">** Select a {{ $column->getLabel() }}</option> |
9 | 9 | @if(!$column->getForeignKey()) |
10 | 10 | <?php |
11 | - $columnValue = old($column->getName())?:($column->getDefaultValue())?:$column->getValue(); |
|
11 | + $columnValue = old($column->getName()) ?: ($column->getDefaultValue()) ?: $column->getValue(); |
|
12 | 12 | ?> |
13 | 13 | @foreach($column->getOptions() as $key=>$value) |
14 | 14 | <option {{ $columnValue==$key?'selected':'' }} value="{{ $key }}">{{ $value }}</option> |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function query($query, $column) |
21 | 21 | { |
22 | - if($column->getOptionsFromTable()) { |
|
22 | + if ($column->getOptionsFromTable()) { |
|
23 | 23 | $option = $column->getOptionsFromTable(); |
24 | - $query->leftjoin($option["table"],$option["table"].'.'.$option["key_field"],"=", $column->getName()); |
|
24 | + $query->leftjoin($option["table"], $option["table"].'.'.$option["key_field"], "=", $column->getName()); |
|
25 | 25 | $query->addSelect($option['table'].'.'.$option['display_field'].' as '.$option['table'].'_'.$option['display_field']); |
26 | 26 | } |
27 | 27 | return $query; |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function indexRender($row, $column) |
35 | 35 | { |
36 | - if($column->getOptionsFromTable()) { |
|
36 | + if ($column->getOptionsFromTable()) { |
|
37 | 37 | $option = $column->getOptionsFromTable(); |
38 | 38 | return $row->{ $option['table'].'_'.$option['display_field'] }; |
39 | - }else{ |
|
39 | + } else { |
|
40 | 40 | $option = $column->getOptions(); |
41 | 41 | $key = $row->{ $column->getField() }; |
42 | - return @$option[ $key ]; |
|
42 | + return @$option[$key]; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | $foreignValue = request('foreign_value'); |
19 | 19 | $table = decrypt(request('table')); |
20 | 20 | $sqlCondition = decrypt(request('sql_condition')); |
21 | - if($foreignKey && $foreignValue && $table) { |
|
21 | + if ($foreignKey && $foreignValue && $table) { |
|
22 | 22 | |
23 | 23 | $data = DB::table($table) |
24 | 24 | ->where($foreignKey, $foreignValue); |
25 | - if($sqlCondition) { |
|
25 | + if ($sqlCondition) { |
|
26 | 26 | $data->whereRaw($sqlCondition); |
27 | 27 | } |
28 | 28 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | return response()->json(['status'=>true, 'data'=>$data], 200, ["X-Frame-Options"=>"SAMEORIGIN"]); |
32 | 32 | |
33 | - }else{ |
|
33 | + } else { |
|
34 | 34 | return response()->json(['status'=>false]); |
35 | 35 | } |
36 | 36 | } |