當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。