public function remove(Request $request, Validator $validator, Field_groups $groups, Fields $fields) { // validation request if ($v = $validator::make($request->all(), $this->removeRules) and $v->fails()) { return redirect()->back()->withInput()->withErrors($v->errors()); } $group = $groups->find((int) $request->id); $fields->where('group_id', $group->id)->where('class_id', $request->class_id)->update(['group_id' => 0]); $group->delete(); return \Redirect::route('admin.groups.items', ['class_id' => $request->class_id]); }
public function edit($class_id, $field_id, Field_types $fieldTypesModel, Fields $fields, Classes $classes, Field_groups $fieldGroupsModel) { $class = $classes->find((int) $class_id); $field = $fields->find((int) $field_id); $field_types = $fieldTypesModel->get(); $field_groups = $fieldGroupsModel->where('class_id', $class->id)->get(); if ($field and $class and $field_types) { return view('admin.fields.edit')->withField($field)->withClass($class)->withFieldTypes($field_types)->withGroups($field_groups); } else { abort(404); } }
/** * removing class and schema * @param Request $request [description] * @param Classes $classes [description] * @param Validator $validator [description] * @return void */ public function remove(Request $request, Classes $classes, Validator $validator, Fields $fields, Field_settings $field_settings, Field_groups $groups) { // validation request if ($v = $validator::make($request->all(), $this->removeRules) and $v->fails()) { return redirect()->back()->withInput()->withErrors($v->errors()); } $class = $classes->find((int) $request->id); $classes->removeSchema($class->shortname); $fields->where('class_id', $class->id)->delete(); $field_settings->where('class_id', $class->id)->delete(); $groups->where('class_id', $class->id)->delete(); $class->delete(); return \Redirect::route('admin.classes.items'); }