@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | private function modalUrl($type) |
| 128 | 128 | { |
| 129 | 129 | switch ($type) { |
| 130 | - case 'edit': |
|
| 131 | - $action = 'update'; |
|
| 132 | - break; |
|
| 133 | - default: |
|
| 134 | - $action = $type; |
|
| 135 | - break; |
|
| 130 | + case 'edit': |
|
| 131 | + $action = 'update'; |
|
| 132 | + break; |
|
| 133 | + default: |
|
| 134 | + $action = $type; |
|
| 135 | + break; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | return route('crudapi.'.$action.'.item', $this->model); |
@@ -153,116 +153,116 @@ discard block |
||
| 153 | 153 | $output = ''; |
| 154 | 154 | |
| 155 | 155 | switch ($type) { |
| 156 | - case 'form-create': |
|
| 157 | - foreach ($fields as $f) { |
|
| 158 | - $ucF = ucfirst($f); |
|
| 156 | + case 'form-create': |
|
| 157 | + foreach ($fields as $f) { |
|
| 158 | + $ucF = ucfirst($f); |
|
| 159 | 159 | |
| 160 | - $input_attr = [ |
|
| 161 | - 'class' => 'form-control', |
|
| 162 | - 'id' => 'createItem'.$f, |
|
| 163 | - 'name' => $f, |
|
| 164 | - ]; |
|
| 160 | + $input_attr = [ |
|
| 161 | + 'class' => 'form-control', |
|
| 162 | + 'id' => 'createItem'.$f, |
|
| 163 | + 'name' => $f, |
|
| 164 | + ]; |
|
| 165 | 165 | |
| 166 | - $output .= '<fieldset class="form-group">'; |
|
| 166 | + $output .= '<fieldset class="form-group">'; |
|
| 167 | 167 | |
| 168 | - $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>'; |
|
| 168 | + $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>'; |
|
| 169 | 169 | |
| 170 | - if ($this->fieldHelper->isIdField($f)) { |
|
| 171 | - $input_attr['type'] = 'select'; |
|
| 170 | + if ($this->fieldHelper->isIdField($f)) { |
|
| 171 | + $input_attr['type'] = 'select'; |
|
| 172 | 172 | |
| 173 | - $output .= '<select '; |
|
| 174 | - foreach ($input_attr as $attr => $value) { |
|
| 175 | - $output .= "{$attr}='{$value}'"; |
|
| 176 | - } |
|
| 173 | + $output .= '<select '; |
|
| 174 | + foreach ($input_attr as $attr => $value) { |
|
| 175 | + $output .= "{$attr}='{$value}'"; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - $relation = $this->getRelatedModel($f); |
|
| 179 | - $output .= '>'; |
|
| 178 | + $relation = $this->getRelatedModel($f); |
|
| 179 | + $output .= '>'; |
|
| 180 | 180 | |
| 181 | - $output .= $this->getRelatedOptions($relation); |
|
| 181 | + $output .= $this->getRelatedOptions($relation); |
|
| 182 | 182 | |
| 183 | - $output .= '</select>'; |
|
| 184 | - } else { |
|
| 185 | - $input_attr['type'] = 'text'; |
|
| 183 | + $output .= '</select>'; |
|
| 184 | + } else { |
|
| 185 | + $input_attr['type'] = 'text'; |
|
| 186 | 186 | |
| 187 | - $output .= '<input '; |
|
| 188 | - foreach ($input_attr as $attr => $value) { |
|
| 189 | - $output .= "{$attr}='{$value}'"; |
|
| 187 | + $output .= '<input '; |
|
| 188 | + foreach ($input_attr as $attr => $value) { |
|
| 189 | + $output .= "{$attr}='{$value}'"; |
|
| 190 | + } |
|
| 191 | + $output .= '>'; |
|
| 190 | 192 | } |
| 191 | - $output .= '>'; |
|
| 193 | + |
|
| 194 | + $output .= '</fieldset>'; |
|
| 192 | 195 | } |
| 196 | + break; |
|
| 197 | + case 'form-edit': |
|
| 198 | + foreach ($fields as $f) { |
|
| 199 | + $ucF = ucfirst($f); |
|
| 193 | 200 | |
| 194 | - $output .= '</fieldset>'; |
|
| 195 | - } |
|
| 196 | - break; |
|
| 197 | - case 'form-edit': |
|
| 198 | - foreach ($fields as $f) { |
|
| 199 | - $ucF = ucfirst($f); |
|
| 201 | + $input_attr = [ |
|
| 202 | + 'class' => 'form-control', |
|
| 203 | + 'id' => 'editItem'.$ucF, |
|
| 204 | + 'name' => $f, |
|
| 205 | + ]; |
|
| 200 | 206 | |
| 201 | - $input_attr = [ |
|
| 202 | - 'class' => 'form-control', |
|
| 203 | - 'id' => 'editItem'.$ucF, |
|
| 204 | - 'name' => $f, |
|
| 205 | - ]; |
|
| 207 | + $output .= '<fieldset class="form-group">'; |
|
| 206 | 208 | |
| 207 | - $output .= '<fieldset class="form-group">'; |
|
| 209 | + $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>'; |
|
| 208 | 210 | |
| 209 | - $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>'; |
|
| 211 | + if ($this->fieldHelper->isIdField($f)) { |
|
| 212 | + $input_attr['type'] = 'select'; |
|
| 210 | 213 | |
| 211 | - if ($this->fieldHelper->isIdField($f)) { |
|
| 212 | - $input_attr['type'] = 'select'; |
|
| 214 | + $output .= '<select '; |
|
| 215 | + foreach ($input_attr as $attr => $value) { |
|
| 216 | + $output .= "{$attr}='{$value}'"; |
|
| 217 | + } |
|
| 213 | 218 | |
| 214 | - $output .= '<select '; |
|
| 215 | - foreach ($input_attr as $attr => $value) { |
|
| 216 | - $output .= "{$attr}='{$value}'"; |
|
| 217 | - } |
|
| 219 | + $relation = $this->getRelatedModel($f); |
|
| 220 | + $output .= '>'; |
|
| 218 | 221 | |
| 219 | - $relation = $this->getRelatedModel($f); |
|
| 220 | - $output .= '>'; |
|
| 222 | + $output .= $this->getRelatedOptions($relation); |
|
| 223 | + $output .= '</select>'; |
|
| 224 | + } else { |
|
| 225 | + $input_attr['type'] = 'text'; |
|
| 221 | 226 | |
| 222 | - $output .= $this->getRelatedOptions($relation); |
|
| 223 | - $output .= '</select>'; |
|
| 224 | - } else { |
|
| 225 | - $input_attr['type'] = 'text'; |
|
| 227 | + $output .= '<input '; |
|
| 228 | + foreach ($input_attr as $attr => $value) { |
|
| 229 | + $output .= "{$attr}='{$value}'"; |
|
| 230 | + } |
|
| 231 | + $output .= '>'; |
|
| 232 | + } |
|
| 226 | 233 | |
| 227 | - $output .= '<input '; |
|
| 228 | - foreach ($input_attr as $attr => $value) { |
|
| 229 | - $output .= "{$attr}='{$value}'"; |
|
| 234 | + $output .= '</fieldset>'; |
|
| 235 | + } |
|
| 236 | + break; |
|
| 237 | + case 'table-headings': |
|
| 238 | + foreach ($fields as $f) { |
|
| 239 | + $output .= '<th>'.ucfirst($f).'</th>'; |
|
| 240 | + } |
|
| 241 | + break; |
|
| 242 | + case 'table-content': |
|
| 243 | + foreach ($fields as $f) { |
|
| 244 | + if ($this->fieldHelper->isIdField($f)) { |
|
| 245 | + $display = $this->getRelatedDisplay($f); |
|
| 246 | + $output .= '<td>'.$display.'</td>'; |
|
| 247 | + } else { |
|
| 248 | + $output .= '<td>'.$this->instance->$f.'</td>'; |
|
| 230 | 249 | } |
| 231 | - $output .= '>'; |
|
| 232 | 250 | } |
| 233 | - |
|
| 234 | - $output .= '</fieldset>'; |
|
| 235 | - } |
|
| 236 | - break; |
|
| 237 | - case 'table-headings': |
|
| 238 | - foreach ($fields as $f) { |
|
| 239 | - $output .= '<th>'.ucfirst($f).'</th>'; |
|
| 240 | - } |
|
| 241 | - break; |
|
| 242 | - case 'table-content': |
|
| 243 | - foreach ($fields as $f) { |
|
| 244 | - if ($this->fieldHelper->isIdField($f)) { |
|
| 245 | - $display = $this->getRelatedDisplay($f); |
|
| 246 | - $output .= '<td>'.$display.'</td>'; |
|
| 247 | - } else { |
|
| 248 | - $output .= '<td>'.$this->instance->$f.'</td>'; |
|
| 251 | + break; |
|
| 252 | + // JavaScript Variables |
|
| 253 | + case 'js-var': |
|
| 254 | + foreach ($fields as $f) { |
|
| 255 | + $output .= 'var '.$f.' = '.$this->instance->$f.'; '; |
|
| 249 | 256 | } |
| 250 | - } |
|
| 251 | - break; |
|
| 252 | - // JavaScript Variables |
|
| 253 | - case 'js-var': |
|
| 254 | - foreach ($fields as $f) { |
|
| 255 | - $output .= 'var '.$f.' = '.$this->instance->$f.'; '; |
|
| 256 | - } |
|
| 257 | - break; |
|
| 258 | - case 'js-modal-create': |
|
| 259 | - foreach ($fields as $f) { |
|
| 260 | - $output .= '"'.$f.'": $(\'#createItem'.$f.'\').val(), '; |
|
| 261 | - } |
|
| 262 | - break; |
|
| 263 | - default: |
|
| 264 | - return; |
|
| 265 | 257 | break; |
| 258 | + case 'js-modal-create': |
|
| 259 | + foreach ($fields as $f) { |
|
| 260 | + $output .= '"'.$f.'": $(\'#createItem'.$f.'\').val(), '; |
|
| 261 | + } |
|
| 262 | + break; |
|
| 263 | + default: |
|
| 264 | + return; |
|
| 265 | + break; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | echo $output; |
@@ -330,17 +330,17 @@ discard block |
||
| 330 | 330 | $class = get_class($field); |
| 331 | 331 | |
| 332 | 332 | switch ($class) { |
| 333 | - case 'App\\Helpers\\CrudApi': |
|
| 334 | - break; |
|
| 335 | - case 'App\\Indicator': |
|
| 336 | - return $field->indicator; |
|
| 337 | - break; |
|
| 338 | - case 'Taskforcedev\\CrudApi\\Helpers\\CrudApi': |
|
| 339 | - return false; |
|
| 340 | - break; |
|
| 341 | - default: |
|
| 342 | - return $field->name; |
|
| 333 | + case 'App\\Helpers\\CrudApi': |
|
| 343 | 334 | break; |
| 335 | + case 'App\\Indicator': |
|
| 336 | + return $field->indicator; |
|
| 337 | + break; |
|
| 338 | + case 'Taskforcedev\\CrudApi\\Helpers\\CrudApi': |
|
| 339 | + return false; |
|
| 340 | + break; |
|
| 341 | + default: |
|
| 342 | + return $field->name; |
|
| 343 | + break; |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |