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


PHP Func::logAppActivity方法代碼示例

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


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

示例1: updateNotifications

 public function updateNotifications($_activity_log)
 {
     \Func::logAppActivity();
     /*
                 *** activity log list ***
                 1. From Store
                 store_bookmark_store
                 destroy_bookmark_store
         2. From Post
                 -store_post
                 -update_post
                 destroy_post - need to take care
                 store_like_post
                 destroy_like_post
                 store_save_post
                 store_comment
                 store_like_comment
                 destroy_like_comment
                 destroy_comment
         3. From User
                 -update_user_profile_picture
                 -update_user
                 destroy_user
                 -update_user_password
                 -update_user_location
                 -update_user_about
                 -update_user_social_network
                 store_follow_user
                 destroy_follow_user
                 store_bookmark_group
                 update_bookmark_group
                 destroy_bookmark_group
                 store_post_group
                 update_post_group
                 destroy_post_group
                 store_follow_post_group
                 destroy_follow_post_group
                 store_save_group
                 update_save_group
                 destroy_save_group
                 store_follow_save_group
                 destroy_follow_save_group
     */
     switch ($_activity_log->action) {
         /* Store Starts */
         case "store_bookmark_store":
         case "destroy_bookmark_store":
             break;
             /* Store Ends, Post Starts */
         /* Store Ends, Post Starts */
         case "store_post":
         case "update_post":
             break;
         case "destroy_post":
             // need to modify
             if ($_activity_log->obj_type == "post") {
                 $notifications = $this->notification->where('obj_id', '=', $_activity_log->obj_id)->where('obj_type', '=', 'App\\Post')->get();
                 foreach ($notifications as $item) {
                     $item->delete();
                 }
             }
             break;
         case "store_like_post":
             if ($_activity_log->obj_type == "post") {
                 $post = $this->post->with('user', 'likesCount')->where('posts.id', '=', $_activity_log->obj_id)->first();
                 if ($post) {
                     if ($post->user_id == $_activity_log->user_id) {
                         break;
                     }
                     $likes = $this->like->with('user')->where('post_id', '=', $post->id)->orderBy('created_at', 'DESC')->get();
                     $content = "";
                     $counter = 0;
                     // Start
                     foreach ($likes as $item) {
                         if ($counter != 0) {
                             $content .= ", ";
                         }
                         $content .= "<a href=\"#/tab/account/" . $item->user->slug . "/notification\" onclick=\"event.stopPropagation();\">" . $item->user->first_name . " " . $item->user->last_name . "</a>";
                         if ($post->likesCount > 3) {
                             if ($counter >= 1) {
                                 $content .= " and " . ($post->likesCount - 2) . " more people";
                                 break;
                             }
                         }
                         $counter++;
                     }
                     $content .= " likes your post.";
                     // End
                     $notification = $this->notification->where('user_id', '=', $post->user_id)->where('obj_id', '=', $_activity_log->obj_id)->where('action', '=', "like_post")->where('obj_type', '=', 'App\\Post')->first();
                     if ($notification) {
                         $notification->delete();
                     }
                     $notification = $this->notification->firstOrCreate(['initiator_id' => \Auth::user()->id, 'user_id' => $post->user_id, 'target_src' => "/post/" . $post->id, 'action' => "like_post", 'obj_id' => $_activity_log->obj_id, 'obj_type' => "App\\Post"]);
                     $notification->contents = $content;
                     $notification->save();
                     $user = $this->user->where('id', '=', $post->user_id)->first();
                     \Func::sendPushNotification($user, strip_tags($content));
                 }
             }
             break;
//.........這裏部分代碼省略.........
開發者ID:bbig979,項目名稱:shoppyst,代碼行數:101,代碼來源:CommonRepositoryEloquent.php


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