예제 #1
0
 public function getCreatefield(Request $request)
 {
     $this->validate($request, ['id' => 'required|integer', 'name' => 'required|alpha_num']);
     $req = InterRequest::find($request->input('id'));
     $field = new Field();
     $field->name = $request->input('name');
     $field->requestid = $req->id;
     if (!$field->save()) {
         return Redirect::back();
     }
     $data = $this->LoadDataByID($request->input('id'));
     $req = array();
     $number = 0;
     $arr = array_keys($data[0]);
     $arr[sizeof($arr)] = $request->input('name');
     $req[$number++] = $arr;
     for ($i = 0; $i < sizeof($data); $i++) {
         $data[$i][sizeof($data[$i])] = "null";
     }
     for ($j = 0; $j < sizeof($data); $j++) {
         $req[$number++] = array_values($data[$j]);
     }
     $this->SaveData($request->input('id'), $req);
     return $field->id;
 }
예제 #2
0
파일: Field.php 프로젝트: encry2024/inv_5_2
 public static function importField($request)
 {
     $new_field = new Field();
     $new_field->category_id = $request->get("category_id");
     $new_field->category_label = $request->get("category_label");
     $new_field->save();
 }
예제 #3
0
 public static function storeCategory($f_requests, $request, $category)
 {
     $category->name = $request['name'];
     $category->save();
     $ctg_id = $category->id;
     $ctg_name = $category->name;
     foreach ($f_requests->category_label as $ctg_label) {
         $field = new Field();
         $field->category_id = $ctg_id;
         $field->category_label = $ctg_label;
         $field->save();
     }
     return redirect()->route('category.create')->with('success_msg', 'Category :: ' . $ctg_name . ' is successfully saved.');
 }
예제 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if (!Auth::check()) {
         return redirect('/auth/login');
     }
     $field = new Field();
     $field->element_id = $request->element_id;
     $field->type = $request->type;
     $field->name = $request->name;
     $field->validation = $request->validation;
     $field->settings = $request->settings;
     $f = Field::orderBy('sort', 'DESC')->first();
     if ($f != null) {
         $field->sort = $f->sort + 1;
     } else {
         $field->sort = 1;
     }
     $field->save();
     return $request->element_id;
 }
예제 #5
0
 public function testImport(Request $request)
 {
     $new_category = new Field();
     $new_category->category_id = $request->get("category_id");
     $new_category->category_label = $request->get("category_label");
     $new_category->save();
 }
예제 #6
0
 private function addPresets(Form $form, $fid)
 {
     $preset = Form::where('fid', '=', $fid)->first();
     $field_assoc = array();
     $form->layout = $preset->layout;
     foreach ($preset->fields()->get() as $field) {
         $new = new Field();
         $new->pid = $form->pid;
         $new->fid = $form->fid;
         $new->order = $field->order;
         $new->type = $field->type;
         $new->name = $field->name;
         $new->slug = $field->slug . '_' . $form->slug;
         $new->desc = $field->desc;
         $new->required = $field->required;
         $new->default = $field->default;
         $new->options = $field->options;
         $new->save();
         $field_assoc[$field->flid] = $new->flid;
     }
     $xmlArray = FormController::xmlToArray($form->layout);
     for ($i = 0; $i < sizeof($xmlArray); $i++) {
         if ($xmlArray[$i]['tag'] == 'ID') {
             $temp = $field_assoc[$xmlArray[$i]['value']];
             $xmlArray[$i]['value'] = $temp;
         }
     }
     $x = new FieldNavController();
     $xmlString = $x->valsToXML($xmlArray);
     $form->layout = $xmlString;
     $form->save();
 }