当前位置: 首页>>代码示例>>PHP>>正文


PHP Topic::find方法代码示例

本文整理汇总了PHP中Topic::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::find方法的具体用法?PHP Topic::find怎么用?PHP Topic::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Topic的用法示例。


在下文中一共展示了Topic::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $topic = Topic::find($id);
     $topic->increment('views');
     $posts = $topic->posts;
     return View::make('topic')->with('topic', $topic)->with('posts', $posts);
 }
开发者ID:vinamilvinamil,项目名称:chatterr,代码行数:13,代码来源:TopicController.php

示例2: beforeSave

 public function beforeSave($options = array())
 {
     //parent::beforeSave($options);
     //print_r($this->data);
     $loggedInUser = AuthComponent::user();
     $found = false;
     $userId = $loggedInUser['user_id'];
     $this->data['Post']['post_by'] = $userId;
     $this->data['Post']['post_date'] = (new DateTime())->format('Y-m-d');
     //format('Y-m-d H:i:s')
     if (!empty($this->data['Topic']['topic_subject'])) {
         $str = $this->data['Topic']['topic_subject'];
         $num = $this->data['Post']['post_cat'];
         $subject = new Topic();
         $found = $subject->find('first', array('conditions' => array('Topic.topic_subject LIKE' => $str, 'Topic.topic_cat =' => $num)));
         if (!$found) {
             $subject->create();
             //create topic
             $subject->save(array('topic_subject' => $this->data['Topic']['topic_subject'], 'topic_date' => (new DateTime())->format('Y-m-d'), 'topic_cat' => $this->data['Post']['post_cat'], 'topic_by' => $userId));
             //see also save associated model method cakephp
             $this->data['Post']['post_topic'] = $this->Topic->getLastInsertId();
             return true;
         }
         $this->data['Post']['post_topic'] = $found['Topic']['topic_id'];
         return true;
     }
     //nothing
     return true;
 }
开发者ID:s3116979,项目名称:BulletinBoard,代码行数:29,代码来源:Post.php

示例3: show

 public function show($id = null)
 {
     $data = [];
     $data['topic'] = Topic::find($id);
     $data['answers'] = $data['topic']->answers()->orderBy('created_at', 'desc')->get();
     return View::make('forum::topic_show', $data);
 }
开发者ID:roffjump,项目名称:forum,代码行数:7,代码来源:TopicController.php

示例4: topicDetail

 public function topicDetail()
 {
     $topic_id = Input::get('topic_id');
     $topic = Topic::find($topic_id);
     if (!isset($topic)) {
         return Response::view('errors.missing');
     }
     //预载入
     $gifts = Gift::where('topic_id', $topic->id)->with(['giftPosters' => function ($query) {
         $query->orderBy('created_at', 'asc');
     }])->get();
     $number = 1;
     foreach ($gifts as $gift) {
         $gift->img = $gift->giftPosters[0]->url;
         $gift->number = $number++;
     }
     // $gifts = Gift::where('topic_id', '=', $topic->id)->get();
     // if(isset($gifts))
     // {	$number = 1;
     // 	foreach($gifts as $gift)
     // 	{
     // 		$url = GiftPoster::where('gift_id','=',$gift->id)->first()->url;
     // 		// $gift->img = StaticController::imageWH($url);
     // 		$gift->img = $url;
     // 		$gift->number = $number++;
     // 	}
     // }
     $gifts = $this->isGiftLike($gifts);
     $type = $this->isTopicLike($topic_id);
     return View::make('pc.subject')->with(array('topic' => $topic, 'gifts' => $gifts, 'type' => $type));
 }
开发者ID:Jv-Juven,项目名称:gift,代码行数:31,代码来源:PcDetailController.php

示例5: getTopicCommentMore

 public function getTopicCommentMore()
 {
     $topic_id = Input::get('topic_id');
     $topic = Topic::find($topic_id);
     $comments = $topic->hasManyTopicComments;
     return View::make('话题评论内容')->with('comments', $comments)->with('links', $this->link());
 }
开发者ID:Jv-Juven,项目名称:opera-1,代码行数:7,代码来源:ColumnPageController.php

示例6: getDayTopViewPosts

 public static function getDayTopViewPosts($start = 0, $limit = 10)
 {
     Counter::checkAll(Topic::ENTITY_TYPE);
     $query = Topic::find()->join("user")->join("group")->join("rating")->join("counter");
     $query = $query->order("desc", "[Counter.dayCount]")->where("[Counter.dayCount]>0");
     $results = $query->range($start, $limit);
     return $results;
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:8,代码来源:Topic.php

示例7: test_find

 function test_find()
 {
     $name = "Writing";
     $test_topic = new Topic($name);
     $test_topic->save();
     $name2 = "Interview";
     $test_topic2 = new Topic($name2);
     $test_topic2->save();
     $result = Topic::find($test_topic->getId());
     $this->assertEquals($test_topic, $result);
 }
开发者ID:umamiMike,项目名称:promptr,代码行数:11,代码来源:TopicTest.php

示例8: createOrDelete

 public function createOrDelete($id)
 {
     $topic = Topic::find($id);
     if (Favorite::isUserFavoritedTopic(Auth::user(), $topic)) {
         Auth::user()->favoriteTopics()->detach($topic->id);
     } else {
         Auth::user()->favoriteTopics()->attach($topic->id);
         Notification::notify('topic_favorite', Auth::user(), $topic->user, $topic);
     }
     Flash::success(lang('Operation succeeded.'));
     return Redirect::route('topics.show', $topic->id);
 }
开发者ID:bobken,项目名称:phphub,代码行数:12,代码来源:FavoritesController.php

示例9: addMessage

 /**
  * addMessage-funktio lähettää User mallille käskyn lisätä uusi viesti parametrina saatuun keskusteluun,jos viesti on tyhjä lähetetään virheilmoitus
  */
 public static function addMessage($id)
 {
     $params = $_POST;
     if ($params['content'] != null && !ctype_space($params['content'])) {
         $message = Message::createMessage($id, $params['content']);
         $messages = Message::all($id);
         $topic = Topic::find($id);
         View::make('keskustelu.html', array('topic' => $topic, 'messages' => $messages));
     }
     $messages = Message::all($id);
     $topic = Topic::find($id);
     View::make('keskustelu.html', array('topic' => $topic, 'messages' => $messages, 'error' => 'Viestisi oli tyhjä'));
 }
开发者ID:hyttijan,项目名称:Tsoha-Bootstrap,代码行数:16,代码来源:topic_controller.php

示例10: createOrDelete

 public function createOrDelete($id)
 {
     $topic = Topic::find($id);
     if (Attention::isUserAttentedTopic(Auth::user(), $topic)) {
         $message = lang('Successfully remove attention.');
         Auth::user()->attentTopics()->detach($topic->id);
     } else {
         $message = lang('Successfully_attention');
         Auth::user()->attentTopics()->attach($topic->id);
         Notification::notify('topic_attent', Auth::user(), $topic->user, $topic);
     }
     Flash::success($message);
     return Redirect::route('topics.show', $topic->id);
 }
开发者ID:fcode520,项目名称:phphub,代码行数:14,代码来源:AttentionsController.php

示例11: getActivePostsCount

 /**
  * TODO: how to define active posts?
  *
  * Now the method count all posts in a given category
  * @param null $categoryId
  * @return mixed
  */
 public function getActivePostsCount($categoryId = null)
 {
     $query = Topic::find()->join("group");
     if ($categoryId !== null) {
         $this->id = $categoryId;
         $subs = $this->children();
         $where = "[Group.categoryId] IN (?";
         $args = [$categoryId];
         for ($i = 0, $count = count($subs); $i < $count; $i++) {
             $where .= ',?';
             $args[] = $subs[$i]->id;
         }
         $where .= ')';
         $query = $query->where($where, $args);
     }
     return $query->count();
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:24,代码来源:Category.php

示例12: actionDetail

 /**
  * View group detail
  * @param $groupId
  */
 public function actionDetail($groupId)
 {
     $group = Group::get($groupId);
     RAssert::not_null($group);
     $group->category = Category::get($group->categoryId);
     $group->groupCreator = User::get($group->creator);
     $counter = $group->increaseCounter();
     // get latest 20 posts in the group
     $posts = Topic::find("groupId", $groupId)->join("user")->order_desc("createdTime")->range(0, 20);
     $data = ['group' => $group, 'counter' => $counter->totalCount, 'latestPosts' => $posts];
     $isLogin = Rays::isLogin();
     $data['hasJoined'] = $isLogin && GroupUser::isUserInGroup(Rays::user()->id, $group->id);
     $data['isManager'] = $isLogin && $group->creator == Rays::user()->id;
     $this->setHeaderTitle($group->name);
     $this->addCss("/public/css/post.css");
     $this->render('detail', $data, false);
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:21,代码来源:GroupController.php

示例13: forumIdWrite

 public function forumIdWrite($id)
 {
     $json = Input::get('json');
     $data = json_decode($json);
     $writer = Student::where('auth', '=', $data->auth)->first();
     $sn = Topic::max('sn') + 1;
     $body = base64_decode($data->body);
     $topics = Topic::find($id);
     $topics->sn = $sn;
     $topics->save();
     $commit = new Commit();
     $commit->stu_id = $writer->id;
     $commit->topic_id = $id;
     $commit->body = $body;
     $commit->day = date("Y/m/d");
     $commit->save();
     return "suc";
 }
开发者ID:danncsc,项目名称:DaanX,代码行数:18,代码来源:ForumController.php

示例14: getUserPlusTopics

 public static function getUserPlusTopics($userId, $start = 0, $limit = 0)
 {
     $ratings = Rating::find(["entityType", Topic::ENTITY_TYPE, "userId", $userId, "valueType", self::VALUE_TYPE, "value", self::VALUE, "tag", self::TAG])->all();
     if ($ratings == null || empty($ratings)) {
         return array();
     }
     $query = Topic::find()->join("user")->join("group")->order_desc("id");
     if ($ratings != null && !empty($ratings)) {
         $where = "[id] in (";
         $args = array();
         for ($count = count($ratings), $i = 0; $i < $count; $i++) {
             $where .= "?" . ($i < $count - 1 ? "," : "");
             $args[] = $ratings[$i]->entityId;
         }
         unset($ratings);
         $where .= ")";
         $query = $query->where($where, $args);
     }
     return $start != 0 || $limit != 0 ? $query->range($start, $limit) : $query->all();
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:20,代码来源:RatingPlus.php

示例15: getUserLikePosts

 public static function getUserLikePosts($userId, $start = 0, $limit = 0)
 {
     $likes = RatingLike::find(["entityType", Topic::ENTITY_TYPE, "userId", $userId])->all();
     $query = Topic::find()->order_desc("id");
     if (!empty($likes)) {
         $args = [];
         $where = "[id] in (";
         for ($i = 0, $count = count($likes); $i < $count; $i++) {
             $args[] = $likes[$i]->entityId;
             $where .= '?' . ($i < $count - 1) ? "," : "";
         }
         unset($likes);
         $where .= ")";
         $query = $query->where($where, $args);
     }
     if ($start != 0 || $limit != 0) {
         return $query->range($start, $limit);
     } else {
         return $query->all();
     }
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:21,代码来源:RatingLike.php


注:本文中的Topic::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。