Beispiel #1
0
 public function update()
 {
     $input = \Request::all();
     if (isset($input['name']) && $input['name'] != '') {
         $uicomponent = UIComponents::firstOrCreate(['name' => $input['name']]);
         if (isset($uicomponent)) {
             if (isset($uicomponent['obj'])) {
                 $arr = json_decode($uicomponent->obj, true);
             } else {
                 $arr = [];
             }
             if (isset($input['images'])) {
                 $arr['images'] = $input['images'];
                 $uicomponent->obj = json_encode($arr);
                 $uicomponent->update();
                 return \Redirect::action('Admin\\UIComponentsController@show', ['name' => $uicomponent->name]);
             } elseif (isset($input['html'])) {
                 $arr['html'] = $input['html'];
                 $uicomponent->obj = json_encode($arr);
                 $uicomponent->update();
                 return \Redirect::action('Admin\\UIComponentsController@show', ['name' => $uicomponent->name]);
             } elseif (isset($input['configuration'])) {
                 $arr['configuration'] = $input['configuration'];
                 $uicomponent->obj = json_encode($arr);
                 $uicomponent->update();
                 return \Redirect::action('Admin\\UIComponentsController@show', ['name' => $uicomponent->name]);
             } else {
                 return 'error: invalid data received';
             }
         } else {
             return 'error: ui-component with the name ' . $input['name'] . ' either does not exist or cannot be created';
         }
     } else {
         return 'error: ui-component name is not received';
     }
 }