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'); }
public function destroy($id) { $parameter = Parameter::findOrFail($id); $parameter->delete($id); Session::flash('message', 'fue eliminado de nuestros registros.'); return redirect()->route('parametros.index'); }
public function store(Request $request) { $emp = Session::get('empresa'); Parameter::where('par_company', $emp)->forceDelete(); Parameter::create($request->all()); return view('parameters')->with('data', $request->all()); }
public function edit($id) { $view = Auth::user()->getView(); $parameters = Parameter::all(); $parameterLevel = Parameterlevel::findOrFail($id); return view('parameterLevels.edit', compact('parameterLevel', 'parameters', 'view')); }
public function edit($id) { $view = Auth::user()->getView(); $parameters = Parameter::all(); $samplings = Sampling::all(); $record = Record::findOrFail($id); return view('records.edit', compact('record', 'parameters', 'samplings', 'view')); }
public function vote(Poll $poll, Request $request) { $user = Auth::user(); if (Vote::where('user_id', $user->id)->where('poll_id', $poll->id)->exists()) { return ['hasCallback' => 0, 'callback' => '', 'hasMsg' => 1, 'msgType' => 'danger', 'msg' => 'you have beed voted', 'returns' => '']; } Vote::create(['user_id' => $user->id, 'poll_id' => $poll->id, 'parameter_id' => $request->input('vote')]); Parameter::find($request->input('vote'))->addVote(); $parameters = $poll->parameters()->get(); $total_votes = $parameters->sum('num_vote'); if ($total_votes == 0) { $total_votes = 1; } return ['hasCallback' => 1, 'callback' => 'poll_voted', 'hasMsg' => 1, 'msg' => 'Voted Successfull', 'returns' => ['total_votes' => $total_votes, 'parameters' => $parameters]]; }
function update(Request $request, $id) { $input = $request->all(); $files = $request->file('test_files'); if (!empty($files[0])) { foreach ($files as $file) { $fileName = $file->getClientOriginalName(); $file->move(public_path() . '/TestFiles/' . $id, $fileName); $file = new TestFile(); $file::create(array('file_name' => $fileName)); } } $getParam = Parameter::where('name', '=', $input['parameter'])->first(); if (!empty($getParam)) { $arr['parameter_id'] = $getParam->id; } $getState = Parameter::where('name', '=', $input['state'])->first(); if (!empty($getState)) { $arr['state_id'] = $getState->id; } $getMethod = Method::where('name', '=', $input['method'])->first(); if (!empty($getMethod)) { $arr['method_id'] = $getMethod->id; } $getTestMethod = TestMethod::where('name', '=', $input['test_method'])->first(); if (!empty($getTestMethod)) { $arr['test_method_id'] = $getTestMethod->id; } $test = Test::find($id); $test->update($arr); // update test items // DB::table('test_processes')->where('test_id', '=', $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' => $id, 'item_id' => $value, 'status' => 1)); } } Session::flash('flash_message', 'Test has been updated successfully.'); Session::flash('flash_type', 'alert-success'); return redirect('admin/tests'); }
/** * Remove the specified resource from storage. * * @param Parameter $parameter * @return Response */ public function destroy($parameter) { $parameter->delete(); }