本文整理汇总了PHP中Func::sendPushNotification方法的典型用法代码示例。如果您正苦于以下问题:PHP Func::sendPushNotification方法的具体用法?PHP Func::sendPushNotification怎么用?PHP Func::sendPushNotification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func::sendPushNotification方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
//.........这里部分代码省略.........
示例2: sendNotificationtoModerators
public function sendNotificationtoModerators()
{
$moderators = array(1, 2, 3);
foreach ($moderators as $moderator) {
$user = $this->user->where('id', '=', $moderator)->first();
\Func::sendPushNotification($user, strip_tags("New Look has posted. Check it out."));
}
}