@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | public function handle() |
33 | 33 | { |
34 | 34 | |
35 | - if($this->option("generate")) { |
|
35 | + if ($this->option("generate")) { |
|
36 | 36 | $this->info("== Generating Seeder =="); |
37 | 37 | $this->generateSeeder(); |
38 | 38 | $this->info("== Finish =="); |
39 | - }else{ |
|
39 | + } else { |
|
40 | 40 | $this->info("== Importing the seeder =="); |
41 | - $this->call("db:seed",["--class"=>"CbMigrationSeeder"]); |
|
41 | + $this->call("db:seed", ["--class"=>"CbMigrationSeeder"]); |
|
42 | 42 | $this->info("== Finish =="); |
43 | 43 | } |
44 | 44 | |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | $php_string = ""; |
51 | 51 | $additional_tables = cbConfig("ADDITIONAL_DATA_MIGRATION"); |
52 | 52 | |
53 | - foreach($tables as $table) { |
|
54 | - if(substr($table,0,3) == "cb_" || in_array($table, $additional_tables)) { |
|
53 | + foreach ($tables as $table) { |
|
54 | + if (substr($table, 0, 3) == "cb_" || in_array($table, $additional_tables)) { |
|
55 | 55 | $this->info("Create seeder for table : ".$table); |
56 | 56 | $rows = DB::table($table)->get(); |
57 | 57 | $data = []; |
58 | - foreach($rows as $i=>$row) { |
|
58 | + foreach ($rows as $i=>$row) { |
|
59 | 59 | $data[$i] = []; |
60 | - foreach($row as $key=>$val) { |
|
60 | + foreach ($row as $key=>$val) { |
|
61 | 61 | $data[$i][$key] = $val; |
62 | 62 | } |
63 | 63 | } |
64 | - if(count($data)!=0) { |
|
64 | + if (count($data) != 0) { |
|
65 | 65 | $php_string .= 'DB::table(\''.$table.'\')->delete();'."\n\t\t\t"; |
66 | 66 | $php_string .= 'DB::table(\''.$table.'\')->insert('.min_var_export($data).');'."\n\t\t\t"; |
67 | 67 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $composer_path = ''; |
92 | 92 | if (file_exists(getcwd().'/composer.phar')) { |
93 | 93 | $composer_path = '"'.PHP_BINARY.'" '.getcwd().'/composer.phar'; |
94 | - }else{ |
|
94 | + } else { |
|
95 | 95 | $composer_path = 'composer'; |
96 | 96 | } |
97 | 97 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $this->info("== Generating Seeder =="); |
37 | 37 | $this->generateSeeder(); |
38 | 38 | $this->info("== Finish =="); |
39 | - }else{ |
|
39 | + } else{ |
|
40 | 40 | $this->info("== Importing the seeder =="); |
41 | 41 | $this->call("db:seed",["--class"=>"CbMigrationSeeder"]); |
42 | 42 | $this->info("== Finish =="); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $composer_path = ''; |
92 | 92 | if (file_exists(getcwd().'/composer.phar')) { |
93 | 93 | $composer_path = '"'.PHP_BINARY.'" '.getcwd().'/composer.phar'; |
94 | - }else{ |
|
94 | + } else{ |
|
95 | 95 | $composer_path = 'composer'; |
96 | 96 | } |
97 | 97 |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | $this->setButtonDetail(true); |
30 | 30 | $this->setButtonSave(true); |
31 | 31 | $this->setButtonLimitPage(true); |
32 | - $this->hideButtonDeleteWhen(function ($row) { return false; }); |
|
33 | - $this->hideButtonDetailWhen(function ($row) { return false; }); |
|
34 | - $this->hideButtonEditWhen(function ($row) { return false; }); |
|
35 | - $this->style(function () { return null; }); |
|
36 | - $this->javascript(function () { return null; }); |
|
32 | + $this->hideButtonDeleteWhen(function($row) { return false; }); |
|
33 | + $this->hideButtonDetailWhen(function($row) { return false; }); |
|
34 | + $this->hideButtonEditWhen(function($row) { return false; }); |
|
35 | + $this->style(function() { return null; }); |
|
36 | + $this->javascript(function() { return null; }); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function style(callable $style) { |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @param ButtonColor $color |
138 | 138 | * @param string $attributes |
139 | 139 | */ |
140 | - public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null) |
|
140 | + public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null) |
|
141 | 141 | { |
142 | - $color = ($color)?:ButtonColor::DARK_BLUE; |
|
142 | + $color = ($color) ?: ButtonColor::DARK_BLUE; |
|
143 | 143 | |
144 | 144 | $model = new IndexActionButtonModel(); |
145 | 145 | $model->setLabel($label); |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | * @param $fontAwesome_icon |
195 | 195 | * @param ButtonColor|string $color |
196 | 196 | */ |
197 | - public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false) |
|
197 | + public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false) |
|
198 | 198 | { |
199 | 199 | $new = new AddActionButtonModel(); |
200 | 200 | $new->setLabel($label); |
201 | - $new->setIcon($fontAwesome_icon?:"fa fa-bars"); |
|
202 | - $new->setColor($color?:"primary"); |
|
201 | + $new->setIcon($fontAwesome_icon ?: "fa fa-bars"); |
|
202 | + $new->setColor($color ?: "primary"); |
|
203 | 203 | $new->setUrl($url_target); |
204 | 204 | $new->setCondition($condition_callback); |
205 | 205 | $new->setConfirmation($confirmation); |
@@ -30,9 +30,9 @@ |
||
30 | 30 | */ |
31 | 31 | public function handle() |
32 | 32 | { |
33 | - if($this->option("password") == "AUTO") { |
|
33 | + if ($this->option("password") == "AUTO") { |
|
34 | 34 | $password = Str::random(16); |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | $password = $this->option("password"); |
37 | 37 | } |
38 | 38 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | if($this->option("password") == "AUTO") { |
34 | 34 | $password = Str::random(16); |
35 | - }else{ |
|
35 | + } else{ |
|
36 | 36 | $password = $this->option("password"); |
37 | 37 | } |
38 | 38 |
@@ -32,12 +32,12 @@ |
||
32 | 32 | { |
33 | 33 | $this->info($this->description); |
34 | 34 | $option = $this->option("module"); |
35 | - if($option == "ALL") { |
|
35 | + if ($option == "ALL") { |
|
36 | 36 | $tables = DB::connection()->getDoctrineSchemaManager()->listTableNames(); |
37 | - foreach($tables as $table) { |
|
37 | + foreach ($tables as $table) { |
|
38 | 38 | $this->generate($table); |
39 | 39 | } |
40 | - }else{ |
|
40 | + } else { |
|
41 | 41 | $this->generate($option); |
42 | 42 | } |
43 | 43 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | foreach($tables as $table) { |
38 | 38 | $this->generate($table); |
39 | 39 | } |
40 | - }else{ |
|
40 | + } else{ |
|
41 | 41 | $this->generate($option); |
42 | 42 | } |
43 | 43 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | $key = $parameters[0]; |
31 | 31 | if(isset($this->data[$key])) { |
32 | 32 | return $this->data[$key]; |
33 | - }else{ |
|
33 | + } else{ |
|
34 | 34 | return null; |
35 | 35 | } |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if(Schema::hasColumn($this->data['table'], $column->getField())) { |
78 | 78 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
79 | 79 | } |
80 | - }else{ |
|
80 | + } else{ |
|
81 | 81 | $query->addSelect($column->getField()); |
82 | 82 | } |
83 | 83 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | if(isset($this->data['hook_search_query'])) { |
91 | 91 | $query = call_user_func($this->data['hook_search_query'], $query); |
92 | - }else{ |
|
92 | + } else{ |
|
93 | 93 | $query->where(function ($where) use ($columns) { |
94 | 94 | /** |
95 | 95 | * @var $where Builder |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | if(strpos($column->getField(),".") === false) { |
100 | 100 | $field = $this->data['table'].'.'.$column->getField(); |
101 | - }else{ |
|
101 | + } else{ |
|
102 | 102 | $field = $column->getField(); |
103 | 103 | } |
104 | 104 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
118 | 118 | $query->orderBy(request('order_by'), request('order_sort')); |
119 | 119 | } |
120 | - }else{ |
|
120 | + } else{ |
|
121 | 121 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
122 | 122 | } |
123 | 123 | |
@@ -126,7 +126,9 @@ discard block |
||
126 | 126 | |
127 | 127 | public function getIndex() |
128 | 128 | { |
129 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
129 | + if(!module()->canBrowse()) { |
|
130 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
131 | + } |
|
130 | 132 | |
131 | 133 | $query = $this->repository(); |
132 | 134 | $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
@@ -153,7 +155,9 @@ discard block |
||
153 | 155 | |
154 | 156 | public function getAdd() |
155 | 157 | { |
156 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
158 | + if(!module()->canCreate()) { |
|
159 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
160 | + } |
|
157 | 161 | |
158 | 162 | $data = []; |
159 | 163 | $data['page_title'] = $this->data['page_title'].' : Add'; |
@@ -163,7 +167,9 @@ discard block |
||
163 | 167 | |
164 | 168 | public function postAddSave() |
165 | 169 | { |
166 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
170 | + if(!module()->canCreate()) { |
|
171 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
172 | + } |
|
167 | 173 | |
168 | 174 | try { |
169 | 175 | $this->validation(); |
@@ -204,7 +210,9 @@ discard block |
||
204 | 210 | |
205 | 211 | public function getEdit($id) |
206 | 212 | { |
207 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
213 | + if(!module()->canUpdate()) { |
|
214 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
215 | + } |
|
208 | 216 | |
209 | 217 | $data = []; |
210 | 218 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -215,7 +223,9 @@ discard block |
||
215 | 223 | |
216 | 224 | public function postEditSave($id) |
217 | 225 | { |
218 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
226 | + if(!module()->canUpdate()) { |
|
227 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
228 | + } |
|
219 | 229 | |
220 | 230 | try { |
221 | 231 | $this->validation(); |
@@ -259,7 +269,9 @@ discard block |
||
259 | 269 | |
260 | 270 | public function getDelete($id) |
261 | 271 | { |
262 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
272 | + if(!module()->canDelete()) { |
|
273 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
274 | + } |
|
263 | 275 | |
264 | 276 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
265 | 277 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -286,7 +298,9 @@ discard block |
||
286 | 298 | |
287 | 299 | public function getDetail($id) |
288 | 300 | { |
289 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
301 | + if(!module()->canRead()) { |
|
302 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
303 | + } |
|
290 | 304 | |
291 | 305 | $data = []; |
292 | 306 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __call($method, $parameters) |
28 | 28 | { |
29 | - if($method == "getData") { |
|
29 | + if ($method == "getData") { |
|
30 | 30 | $key = $parameters[0]; |
31 | - if(isset($this->data[$key])) { |
|
31 | + if (isset($this->data[$key])) { |
|
32 | 32 | return $this->data[$key]; |
33 | - }else{ |
|
33 | + } else { |
|
34 | 34 | return null; |
35 | 35 | } |
36 | - }else{ |
|
36 | + } else { |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | } |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | |
48 | 48 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
49 | 49 | |
50 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
51 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
50 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
51 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
52 | 52 | $query->whereNull($this->data['table'].'.deleted_at'); |
53 | 53 | } |
54 | 54 | |
55 | - if(isset($joins)) { |
|
56 | - foreach($joins as $join) |
|
55 | + if (isset($joins)) { |
|
56 | + foreach ($joins as $join) |
|
57 | 57 | { |
58 | 58 | $query->join($join['target_table'], |
59 | 59 | $join['target_table_primary'], |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - foreach($columns as $column) { |
|
66 | + foreach ($columns as $column) { |
|
67 | 67 | /** @var ColumnModel $column */ |
68 | - if($column->getType() != "custom") { |
|
69 | - if(strpos($column->getField(),".") === false) { |
|
70 | - if(Schema::hasColumn($this->data['table'], $column->getField())) { |
|
68 | + if ($column->getType() != "custom") { |
|
69 | + if (strpos($column->getField(), ".") === false) { |
|
70 | + if (Schema::hasColumn($this->data['table'], $column->getField())) { |
|
71 | 71 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
72 | 72 | } |
73 | - }else{ |
|
73 | + } else { |
|
74 | 74 | $query->addSelect($column->getField()); |
75 | 75 | } |
76 | 76 | } |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | $query = getTypeHook($column->getType())->query($query, $column); |
79 | 79 | } |
80 | 80 | |
81 | - if(request()->has('q')) |
|
81 | + if (request()->has('q')) |
|
82 | 82 | { |
83 | - if(isset($this->data['hook_search_query'])) { |
|
83 | + if (isset($this->data['hook_search_query'])) { |
|
84 | 84 | $query = call_user_func($this->data['hook_search_query'], $query); |
85 | - }else{ |
|
86 | - $query->where(function ($where) use ($columns) { |
|
85 | + } else { |
|
86 | + $query->where(function($where) use ($columns) { |
|
87 | 87 | /** |
88 | 88 | * @var $where Builder |
89 | 89 | */ |
90 | - foreach($columns as $column) |
|
90 | + foreach ($columns as $column) |
|
91 | 91 | { |
92 | - if(strpos($column->getField(),".") === false) { |
|
92 | + if (strpos($column->getField(), ".") === false) { |
|
93 | 93 | $field = $this->data['table'].'.'.$column->getField(); |
94 | - }else{ |
|
94 | + } else { |
|
95 | 95 | $field = $column->getField(); |
96 | 96 | } |
97 | 97 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
103 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
104 | 104 | $query = call_user_func($this->data['hook_index_query'], $query); |
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | - if(request()->has(['order_by','order_sort'])) |
|
108 | + if (request()->has(['order_by', 'order_sort'])) |
|
109 | 109 | { |
110 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
110 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
111 | 111 | $query->orderBy(request('order_by'), request('order_sort')); |
112 | 112 | } |
113 | - }else{ |
|
113 | + } else { |
|
114 | 114 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
115 | 115 | } |
116 | 116 | |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | |
120 | 120 | public function getIndex() |
121 | 121 | { |
122 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
122 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
123 | 123 | |
124 | 124 | $query = $this->repository(); |
125 | - $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
|
125 | + $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA")); |
|
126 | 126 | $data['result'] = $result; |
127 | 127 | |
128 | 128 | return view("crudbooster::module.index.index", array_merge($data, $this->data)); |
@@ -134,29 +134,29 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function validation() |
136 | 136 | { |
137 | - if(isset($this->data['validation'])) { |
|
137 | + if (isset($this->data['validation'])) { |
|
138 | 138 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
139 | 139 | if ($validator->fails()) { |
140 | 140 | $message = $validator->messages(); |
141 | 141 | $message_all = $message->all(); |
142 | - throw new CBValidationException(implode(', ',$message_all)); |
|
142 | + throw new CBValidationException(implode(', ', $message_all)); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | public function getAdd() |
148 | 148 | { |
149 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
149 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
150 | 150 | |
151 | 151 | $data = []; |
152 | 152 | $data['page_title'] = $this->data['page_title'].' : Add'; |
153 | 153 | $data['action_url'] = module()->addSaveURL(); |
154 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
154 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | public function postAddSave() |
158 | 158 | { |
159 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
159 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
160 | 160 | |
161 | 161 | try { |
162 | 162 | $this->validation(); |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | $data = columnSingleton()->getAssignmentData(); |
165 | 165 | |
166 | 166 | //Clear data from Primary Key |
167 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
167 | + unset($data[cb()->pk($this->data['table'])]); |
|
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 | - if(isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
173 | + if (isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
174 | 174 | $data = call_user_func($this->data['hook_before_insert'], $data); |
175 | 175 | } |
176 | 176 | |
177 | 177 | $id = DB::table($this->data['table'])->insertGetId($data); |
178 | 178 | |
179 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
179 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
180 | 180 | call_user_func($this->data['hook_after_insert'], $id); |
181 | 181 | } |
182 | 182 | |
183 | 183 | } catch (CBValidationException $e) { |
184 | 184 | Log::debug($e); |
185 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
185 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
186 | 186 | } catch (\Exception $e) { |
187 | 187 | Log::error($e); |
188 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
188 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | if (request('submit') == trans('crudbooster.button_save_more')) { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | public function getEdit($id) |
199 | 199 | { |
200 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
200 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
201 | 201 | |
202 | 202 | $data = []; |
203 | 203 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | public function postEditSave($id) |
210 | 210 | { |
211 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
211 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
212 | 212 | |
213 | 213 | try { |
214 | 214 | $this->validation(); |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | $data = columnSingleton()->getAssignmentData(); |
217 | 217 | |
218 | 218 | //Clear data from Primary Key |
219 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
219 | + unset($data[cb()->pk($this->data['table'])]); |
|
220 | 220 | |
221 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
221 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
222 | 222 | $data['updated_at'] = date('Y-m-d H:i:s'); |
223 | 223 | } |
224 | 224 | |
225 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
225 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
226 | 226 | $data = call_user_func($this->data['hook_before_update'], $id, $data); |
227 | 227 | } |
228 | 228 | |
@@ -230,16 +230,16 @@ discard block |
||
230 | 230 | ->where(cb()->pk($this->data['table']), $id) |
231 | 231 | ->update($data); |
232 | 232 | |
233 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
233 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
234 | 234 | call_user_func($this->data['hook_after_update'], $id); |
235 | 235 | } |
236 | 236 | |
237 | 237 | } catch (CBValidationException $e) { |
238 | 238 | Log::debug($e); |
239 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
239 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
240 | 240 | } catch (\Exception $e) { |
241 | 241 | Log::error($e); |
242 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
242 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -252,15 +252,15 @@ discard block |
||
252 | 252 | |
253 | 253 | public function getDelete($id) |
254 | 254 | { |
255 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
255 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
256 | 256 | |
257 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
257 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
258 | 258 | call_user_func($this->data['hook_before_delete'], $id); |
259 | 259 | } |
260 | 260 | |
261 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
261 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
262 | 262 | |
263 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
263 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
264 | 264 | DB::table($this->data['table']) |
265 | 265 | ->where(getPrimaryKey($this->data['table']), $id) |
266 | 266 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | ->delete(); |
271 | 271 | } |
272 | 272 | |
273 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
273 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
274 | 274 | call_user_func($this->data['hook_after_delete'], $id); |
275 | 275 | } |
276 | 276 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | |
280 | 280 | public function getDetail($id) |
281 | 281 | { |
282 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
282 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
283 | 283 | |
284 | 284 | $data = []; |
285 | 285 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |