public function postUpdateItem(Request $request, $model, $id)
 {
     $item = call_user_func(array($this->class_name, 'find'), $id);
     if (!$item) {
         $item = new $this->class_name();
         $item->id = $this->item_id;
     }
     CrudUtilities::fillItem($request, $item, $this->fields);
     return redirect($this->route_url . '/items');
 }
Пример #2
0
 public function postUpdateField(Request $request)
 {
     $id = intVal($request->input('id'));
     $fieldType = $request->input('type');
     $fieldName = $request->input('name');
     $fieldValue = $request->input('value');
     $item = call_user_func(array($this->class_name, 'findOrFail'), $id);
     if ($fieldType == 'text' || $fieldType == 'number' || $fieldType == 'textarea' || $fieldType == 'email' || $fieldType == 'url' || $fieldType == 'date' || $fieldType == 'datetime' || $fieldType == 'select') {
         $item->{$fieldName} = $fieldValue;
     } else {
         if ($fieldType == 'checkbox') {
             $item->{$fieldName} = $fieldValue == 'true';
         } else {
             if ($fieldType == 'password' && $fieldValue != '') {
                 $item->{$fieldName} = bcrypt($fieldValue);
             }
         }
     }
     CrudUtilities::updateAlias($request, $item, $this->fields);
     $item->save();
 }