Esempio n. 1
0
 function store(Request $request)
 {
     $input = $request->all();
     $testArr = array();
     $getParam = Parameter::where('name', '=', $input['parameter'])->first();
     if (!empty($getParam)) {
         $testArr['parameter_id'] = $getParam->id;
     } else {
         $parameter = new Parameter();
         $parameter->create(array('name' => $input['parameter']));
         $testArr['parameter_id'] = DB::getPdo()->lastInsertId();
     }
     $getState = Parameter::where('name', '=', $input['state'])->first();
     if (!empty($getState)) {
         $testArr['state_id'] = $getState->id;
     } else {
         $state = new State();
         $state->create(array('name' => $input['state']));
         $testArr['state_id'] = DB::getPdo()->lastInsertId();
     }
     $getMethod = Method::where('name', '=', $input['method'])->first();
     if (!empty($getMethod)) {
         $testArr['method_id'] = $getMethod->id;
     } else {
         $method = new Method();
         $method->create(array('name' => $input['method']));
         $testArr['method_id'] = DB::getPdo()->lastInsertId();
     }
     $getTestMethod = TestMethod::where('name', '=', $input['test_method'])->first();
     if (!empty($getTestMethod)) {
         $testArr['test_method_id'] = $getTestMethod->id;
     } else {
         $tmethod = new TestMethod();
         $tmethod->create(array('name' => $input['test_method']));
         $testArr['test_method_id'] = DB::getPdo()->lastInsertId();
     }
     $checkTest = Test::where('parameter_id', '=', $testArr['parameter_id'])->where('parameter_id', '=', $testArr['state_id'])->where('parameter_id', '=', $testArr['method_id'])->where('parameter_id', '=', $testArr['test_method_id'])->first();
     if ($checkTest) {
         $test_id = $checkTest->id;
         Session::flash('flash_message', 'Test already exist.');
     } else {
         $testArr['price'] = 147;
         $test = new Test();
         $test::create($testArr);
         $test_id = DB::getPdo()->lastInsertId();
         Session::flash('flash_message', 'Test created successfully.');
     }
     if ($test_id) {
         DB::table('test_processes')->where('test_id', '=', $test_id)->delete();
         if ($request->has('test_item')) {
             $items = $request->get('test_item');
             foreach ($items as $key => $value) {
                 $process = new Process();
                 $process::create(array('test_id' => $test_id, 'item_id' => $value, 'status' => 1));
             }
         }
     }
     Session::flash('flash_type', 'alert-success');
     return redirect('admin/tests');
 }
Esempio n. 2
0
 public function store(Request $request, Table $table)
 {
     return Method::create($request->all());
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $inputs = Request::all();
     Method::create($inputs);
     return redirect()->route('admin_methods_index')->with('status', 'Method created');
 }