return Extend::where('key', '=', $str)->where('type', '=', $input['type'])->where('id', '<>', $id)->count() == 0; }); $validator->check('key')->is_max(1, __('extend.key_missing'))->is_valid_key(__('extend.key_exists')); $validator->check('label')->is_max(1, __('extend.label_missing')); if ($errors = $validator->errors()) { Input::flash(); Notify::error($errors); return Response::redirect('admin/extend/fields/edit/' . $id); } if ($input['field'] == 'image') { $attributes = Json::encode($input['attributes']); } elseif ($input['field'] == 'file') { $attributes = Json::encode(array('attributes' => array('type' => $input['attributes']['type']))); } else { $attributes = ''; } Extend::update($id, array('type' => $input['type'], 'pagetype' => $input['pagetype'], 'field' => $input['field'], 'key' => $input['key'], 'label' => $input['label'], 'attributes' => $attributes)); Notify::success(__('extend.field_updated')); return Response::redirect('admin/extend/fields/edit/' . $id); }); /* Delete Field */ Route::get('admin/extend/fields/delete/(:num)', function ($id) { $field = Extend::find($id); Query::table(Base::table($field->type . '_meta'))->where('extend', '=', $field->id)->delete(); $field->delete(); Notify::success(__('extend.field_deleted')); return Response::redirect('admin/extend/fields'); }); });
function mod_update() { $mod = new Extend($_GET['mod']); redirect('mod', 'index', array('hsuccess' => $mod->update())); }