/** * Display the specified resource. * * @param int $id * @return Response */ public function show($user, $project_name, Request $request) { $project_id = $request->query('id'); $project = Project::find($project_id); if (is_null($project)) { $project = Session::get('project'); } $stories = Story::where('project_id', $project->id)->get(); $count = $stories->count(); $points = $stories->sum('story_point'); return view('user.project.show', compact('project', 'project_name', 'user', 'project_id', 'stories', 'points', 'count')); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Story::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, 'user_id' => $this->user_id, 'collect' => $this->collect, 'like' => $this->like, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
public static function cheLikeUser($id, $nomination) { if (isset(Yii::$app->user->identity->id)) { if (!isset($id) && $id == null) { return false; } $vote = Vote::find()->where(['user_id' => Yii::$app->user->identity->id, 'story_id' => $id])->one(); if (!empty($vote) && $vote != null) { $story_nomination = Story::find()->where(['id' => $vote->story_id])->one(); if ($story_nomination->nomination === $nomination) { return true; } else { return false; } } else { $vote = Vote::find()->where(['user_id' => Yii::$app->user->identity->id])->all(); $arr = []; foreach ($vote as $k => $v) { $story_nomination = Story::find()->where(['id' => $v->story_id])->one(); if ($story_nomination->nomination === $nomination) { $arr[$story_nomination->nomination] = $story_nomination->nomination; } } if (empty($arr)) { return false; } else { return true; } } } else { return false; } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $story = Story::find($id); if ($story == null) { return response()->json(['error' => 'Not Found Data'], 422); } //자신의 글 확인 if ($story->user_id != $this->token->user_id) { return response()->json(['error' => 'Permission denied'], 403); } $story->delete(); return response()->json('ok', 200); }
?> <?php echo $like_b; ?> <?php } ?> </p> </div> </div> <?php if ($bob->status != User::STATUS_WAIT) { ?> <div class="social-box"> <?php $p = Story::subStrStringMeta($bob->about); ?> <a href="javascript:void(0);" class="icon icon-social icon-fb icon-has-text active " onclick="Share.facebook('http://<?php echo Yii::$app->request->getServerName(); echo Url::to(['site/story', 'id' => $bob->id]); ?> ','<?php echo $bob->name_story; ?> ','http://<?php echo Yii::$app->request->getServerName(); echo Url::to('/web/upload/220_125/') . '220_125_' . $bob->photo; ?> ','<?php echo $p; ?>
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($user, $project_name, $id) { Story::destroy($id); return redirect()->route('{user}.{project}.story.index', ['user' => $user, 'project_name' => $project_name]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Story::find($id)->delete(); return redirect()->route('admin.story.index'); }
/** * Finds the Story model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Story the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Story::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }