Exemple #1
0
 /** Добавляет новый тест в БД */
 public function add(Request $request)
 {
     if ($request->input('training')) {
         $test_type = 'Тренировочный';
     } else {
         $test_type = 'Контрольный';
     }
     $total = $request->input('total');
     $test_time = $request->input('test-time');
     $start = $request->input('start-date') . ' ' . $request->input('start-time');
     $end = $request->input('end-date') . ' ' . $request->input('end-time');
     $structure = '';
     $amount = 0;
     for ($i = 0; $i < $request->input('num-rows'); $i++) {
         $structure .= $this->struct($request->input('num')[$i], $request->input('section')[$i], $request->input('theme')[$i], $request->input('type')[$i]) . ';';
         $amount += $request->input('num')[$i];
     }
     $structure .= $this->struct($request->input('num')[$request->input('num-rows')], $request->input('section')[$request->input('num-rows')], $request->input('theme')[$request->input('num-rows')], $request->input('type')[$request->input('num-rows')]);
     $amount += $request->input('num')[$request->input('num-rows')];
     Test::insert(array('test_name' => $request->input('test-name'), 'test_type' => $test_type, 'amount' => $amount, 'test_time' => $test_time, 'start' => $start, 'end' => $end, 'structure' => $structure, 'total' => $total));
     return redirect()->route('test_create');
 }