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


PHP Post::getPostById方法代码示例

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


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

示例1: createNewNotification

 /**
  * @param $sender
  * @param $receiver
  * @param $object
  */
 private static function createNewNotification($sender, $event)
 {
     $noti = new Notification();
     $noti["sender_id"] = $sender;
     $noti["is_read"] = 0;
     $noti["objectType"] = POST;
     if ($event instanceof FollowEvent) {
         $noti["type"] = FOLLOW;
         $noti["receiver_id"] = $event["following_id"];
         if ($event["follow_type"] == 2) {
             $noti["objectType"] = BOARD;
         } else {
             $noti["objectType"] = USER;
         }
     } else {
         $post = Post::getPostById($event["post_id"]);
         $noti["receiver_id"] = $post["user_id"];
         if ($event instanceof LikeEvent) {
             $noti["type"] = LIKE;
             $noti["objectID"] = $event["post_id"];
         } else {
             if ($event instanceof CommentEvent) {
                 $noti["type"] = COMMENT;
                 $noti["objectID"] = $event["post_id"];
             } else {
                 if ($event instanceof PinEvent) {
                     $noti["type"] = PIN;
                     $noti["objectID"] = $event["post_id"];
                 }
             }
         }
     }
     return $noti;
 }
开发者ID:NhuanTDBK,项目名称:Bluemix-Laravel-Demo,代码行数:39,代码来源:Notification.php

示例2: delete

 /**
  * Delete post
  *
  * @param Request $request
  * @param int $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function delete(Request $request, $id = 0)
 {
     if ($request->isMethod('post')) {
         foreach ($request->input('posts') as $post) {
             $post = Post::getPostById($post);
             if (!empty($post)) {
                 if (!empty($post->image)) {
                     if (Storage::exists('uploads/' . $post->image) && Storage::exists('uploads/fb-' . $post->image)) {
                         Storage::delete('uploads/' . $post->image, 'uploads/fb-' . $post->image);
                     }
                 }
                 $post->delete();
             }
         }
     } else {
         $post = Post::getPostById($id);
         if (!empty($post)) {
             if (!empty($post->image)) {
                 if (Storage::exists('uploads/' . $post->image) && Storage::exists('uploads/fb-' . $post->image)) {
                     Storage::delete('uploads/' . $post->image, 'uploads/fb-' . $post->image);
                 }
             }
             $post->delete();
         }
         return redirect()->back();
     }
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:34,代码来源:PostController.php

示例3: likePost

 public function likePost($post_id)
 {
     if (!Auth::check()) {
         return response()->json('Please login');
     }
     $current_id = Auth::user()->user_id;
     $avatar_link = Auth::user()->avatar_link;
     $name = Auth::user()->name;
     $post = LikeEvent::checkLiked($post_id, $current_id);
     $channel = Post::getPostById($post_id)["user_id"];
     if (!$post) {
         $result = LikeEvent::createLikeEvent($post_id, $current_id);
         $pusher = App::make('pusher');
         $pusher->trigger($channel, 'like', array('name' => $name, 'post_id' => $post_id, 'avatar_link' => $avatar_link));
     } else {
         $result = LikeEvent::removeLikeEvent($post["like_event_id"]);
     }
     return response()->json(["result" => $result]);
 }
开发者ID:NhuanTDBK,项目名称:Bluemix-Laravel-Demo,代码行数:19,代码来源:LikeController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($post_id)
 {
     //
     $post = $this->getPostDetail($post_id)[0];
     $post_stat = $this->getPostDetail($post_id)[1];
     if (Auth::check()) {
         $post["liked"] = LikeEvent::checkLiked($post["post_id"], Auth::user()->user_id);
     }
     $post["comments"] = Post::getCommentsByPostId($post_id);
     $post["likes"] = $post_stat["likes"];
     $post["pins"] = $post_stat["pins"];
     $post["boards"] = Board::getPostsInBoard($post["board_id"]);
     $post["places"] = Place::getPlaceById(Post::getPostById($post_id)['place_id']);
     $recommend = new RecommendController();
     $post["recommend_posts"] = $recommend->getPost($post_id);
     return response()->json($post);
 }
开发者ID:NhuanTDBK,项目名称:Bluemix-Laravel-Demo,代码行数:23,代码来源:PostController.php

示例5: disapprove

 /**
  * Disapprove post
  *
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function disapprove($id)
 {
     $post = Post::getPostById($id);
     if ($post) {
         $post->approve = 0;
         $post->save();
         if ($post->author_id != Auth::user()->id) {
             $notification = new Notification();
             $notification->from = Auth::user()->id;
             $notification->to = $post->author_id;
             $notification->type = 6;
             $notification->save();
         }
     }
     return redirect()->route('admin_posts');
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:22,代码来源:PostController.php

示例6: getPost

 public function getPost($post_id)
 {
     $client = new Client();
     $post = Post::getPostById($post_id);
     $index_name = Config::get('elasticsearch.index_name');
     $post_type = Config::get('elasticsearch.post_type');
     $params = ["index" => $index_name, "analyzer" => 'vi_analyzer', 'text' => $post["description"]];
     $tokens = $client->indices()->analyze($params)["tokens"];
     $search = new SearchController();
     $results = [];
     foreach ($tokens as $token) {
         $query = ["description" => $token["token"]];
         $results[] = $search->search($post_type, $query);
     }
     return $results;
 }
开发者ID:NhuanTDBK,项目名称:FoodieWebOpenshift,代码行数:16,代码来源:RecommendController.php


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