public function show($pid) { $process = new Process(); $process->pid = $pid; $process = Process::findOne($process->pid); return response()->json(array('status' => '200', 'message' => 'Founded', 'result' => $process)); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Process::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created' => $this->created]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'cmdline', $this->cmdline])->andFilterWhere(['like', 'alias', $this->cmdline]); return $dataProvider; }
/** * Map process with same name under one id * @return array */ public static function processMap() { /** @var Process[] $processes */ $processes = Process::find()->all(); $out = []; $names = []; $ignore = ['java']; foreach ($processes as $process) { if (!isset($names[$process->name]) || in_array($process->name, $ignore)) { $names[$process->name] = $process; } $out[$process->id] = $names[$process->name]; } return $out; }
/** * @param Request $request * @param Response $response * @return Object * Принимаем ajax запрос формат json - массив объектов и отправляем текст о успешном добавлении * */ public function saveProcess(Request $request, Response $response) { if ($request->ajax()) { $result = $request->get('json'); $result = json_decode($result); $arr = []; //Поставить заглушку на проверку выбранной опции, как свойства объекта $userObject = $result->user; //$group = $userObject->group; $user = $userObject->users; $stage = $userObject->stages; $progress_id = $userObject->user_progress; $number_lesson = $userObject->number_lesson; $exp_progress = $userObject->exp_progress; User_Progress::create(['progress_id' => $progress_id, 'user_id' => $user, 'experience' => $exp_progress]); foreach ($result as $key => $value) { if ($key == 'D' || $key == 'C' || $key == 'B' || $key == 'A') { array_push($arr, $value); for ($i = 0; $i < count($value); $i++) { $grade_char = $value[$i]->grade; $subject_id = $value[$i]->subject_id; $experience = $value[$i]->sumExp; $gold = $value[$i]->sumGold; $sumTask = $value[$i]->sumTask; Grade::create(['subject_id' => $subject_id, 'user_id' => $user, 'grade_char' => $grade_char, 'sum_tasks' => $sumTask, 'number_lesson' => $number_lesson, 'sum_exp' => $experience, 'sum_gold' => $gold]); } } if ($key == 'task') { for ($i = 0; $i < count($value); $i++) { //$id = $value[$i]->id; $number_task = $value[$i]->number_task; $experience = $value[$i]->experience; $gold = $value[$i]->experience; $rating = $value[$i]->rating; $comment = $value[$i]->comment; Process::create(['user_id' => $user, 'stage' => $stage, 'number_task' => $number_task, 'experience' => $experience, 'gold' => $gold, 'rating' => $rating, 'comment' => $comment, 'number_lesson' => $number_lesson]); } } } return $response->json(['Задачи успешно добавились в БД', $arr]); } }
/** * Finds the Process model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Process the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Process::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getProcess() { return $this->hasOne(Process::className(), ['id' => 'process_id']); }
/** * Remove the specified resource from storage. * * @param int $id * * @return Response */ public function destroy($id) { Process::destroy($id); Session::flash('flash_message', 'Process deleted!'); return redirect('processes'); }