public function destroy($id) { $tagConfigModel = TagConfigModel::on(DBUtils::getDBName())->find($id); $tagConfigModel->delete(); DB::connection(DBUtils::getDBName())->table('mmpoint_table')->where('A', '=', $tagConfigModel->A)->delete(); session()->flash('message', ' Delete successfuly.'); return redirect('ais/tagConfiguration'); }
public function store(Request $request) { $id = $request->input('poiId'); $tagId = $request->input('tagId'); Log::info("into store poiId[" . $id . "] tagId[" . $tagId . "]"); if ($id != null) { $avgChk = Input::has('avg') ? Input::get('avg') : null; $point = PointConfigModel::on(DBUtils::getDBName())->find($id); $point->D = $request->input('poiAtom'); if (isset($avgChk)) { $point->E = "Yes"; } else { $point->E = "No"; } $point->F = $request->input('poiUnit'); $point->G0 = $request->input('poiMax'); $point->G1 = $request->input('poiMin'); $point->save(); session()->flash('message', ' Update successfuly.'); } else { $maxId = DB::connection(DBUtils::getDBName())->table('mmpoint_table')->max('A'); Log::info("saveeee store poiId[" . $maxId . "]"); $avgChk = Input::has('avg') ? Input::get('avg') : null; $point = new PointConfigModel(); $point->setConnection(DBUtils::getDBName()); $point->A = $maxId + 1; $point->D = $request->input('poiAtom'); if (isset($avgChk)) { $point->E = "Yes"; } else { $point->E = "No"; } $point->F = $request->input('poiUnit'); $point->G0 = $request->input('poiMax'); $point->G1 = $request->input('poiMin'); $point->H = $tagId; $tagModel = TagConfigModel::on(DBUtils::getDBName())->newQuery()->where('A', '=', $tagId)->first(); $point->B = $tagModel->B; $mmplant = session()->get('user_mmplant'); if ($mmplant == '1') { // 4-7 $point->C4 = $tagModel->C4; $point->C5 = $tagModel->C5; $point->C6 = $tagModel->C6; $point->C7 = $tagModel->C7; } else { if ($mmplant == '2') { // 4-7 $point->C8 = $tagModel->C8; $point->C9 = $tagModel->C9; $point->C10 = $tagModel->C10; $point->C11 = $tagModel->C11; $point->C12 = $tagModel->C12; $point->C13 = $tagModel->C13; } else { if ($mmplant == '3') { // 4-7 $point->C8 = $tagModel->C8; $point->C9 = $tagModel->C9; $point->C10 = $tagModel->C10; $point->C11 = $tagModel->C11; $point->C12 = $tagModel->C12; $point->C13 = $tagModel->C13; } } } $point->save(); session()->flash('message', ' Save successfuly.'); } //return redirect('ais/pointConfiguration'); return redirect('ais/tag/' . $tagId . '/points'); }