當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Posts::PostDesc方法代碼示例

本文整理匯總了PHP中app\Posts::PostDesc方法的典型用法代碼示例。如果您正苦於以下問題:PHP Posts::PostDesc方法的具體用法?PHP Posts::PostDesc怎麽用?PHP Posts::PostDesc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Posts的用法示例。


在下文中一共展示了Posts::PostDesc方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: likePost

 public static function likePost($input)
 {
     $validation = Validator::make($input, Posts::$likePostRules);
     if ($validation->fails()) {
         return Response::json(array('status' => '0', 'msg' => $validation->getMessageBag()->first()), 200);
     } else {
         $access_token = $input['token'];
         $post_id = $input['post_id'];
         $current_time = new DateTime();
         $user_id = Users::getUserIdByToken($access_token);
         if ($user_id) {
             $uname = Users::getUsername($user_id);
             $other_id = Posts::getPostOwner($post_id);
             $push_status = Users::getPushSettings($other_id);
             $user_det = Users::getUserType($user_id);
             $user_type = $user_det->user_type;
             $push_ids = Users::getUserPushIds($other_id);
             $reg_id = $push_ids->reg_id;
             $device_token = $push_ids->apn_id;
             $post_data = DB::table('likes')->select('*')->where('post_id', $post_id)->where('user_id', $user_id)->first();
             if (!$post_data) {
                 $like_id = DB::table('likes')->insertGetId(array('user_id' => $user_id, 'post_id' => $post_id, 'created_at' => $current_time));
                 if ($user_id != $other_id) {
                     $post_desc = Posts::PostDesc($other_id, $post_id);
                     $notify_message = $uname . " liked your post";
                     $Ninput['sender_id'] = $user_id;
                     $Ninput['receiver_id'] = Posts::getPostOwner($post_id);
                     $Ninput['type_id'] = $like_id;
                     $Ninput['type'] = 'like';
                     $Ninput['title'] = $notify_message;
                     Notifications::addNotification($Ninput);
                     if ($push_status) {
                         Notifications::SendPushNotification($notify_message, '', $device_token, 2, $post_id, $user_id);
                         Notifications::SendPushNotification($notify_message, $reg_id, '', 2, $post_desc, $user_type);
                     }
                 }
                 if ($like_id) {
                     return Response::json(array('status' => '1', 'msg' => 'Post Liked'), 200);
                 } else {
                     return Response::json(array('status' => '0', 'msg' => "Error"), 200);
                 }
             } else {
                 return Response::json(array('status' => '2', 'msg' => 'Post Already liked by user'), 200);
             }
         } else {
             return Response::json(array('status' => '0', 'msg' => "Token Expired"), 200);
         }
     }
 }
開發者ID:Gameonn,項目名稱:connected,代碼行數:49,代碼來源:Posts.php


注:本文中的app\Posts::PostDesc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。