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


PHP Notification::insert方法代码示例

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


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

示例1: notify

 public static function notify($type, User $fromUser, User $toUser, Topic $topic, Reply $reply = null)
 {
     if (Notification::isNotified($fromUser->id, $toUser->id, $topic->id, $type)) {
         return;
     }
     $nowTimestamp = Carbon::now()->toDateTimeString();
     $data = ['from_user_id' => $fromUser->id, 'user_id' => $toUser->id, 'topic_id' => $topic->id, 'reply_id' => $reply ? $reply->id : 0, 'body' => $reply ? $reply->body : '', 'type' => $type, 'created_at' => $nowTimestamp, 'updated_at' => $nowTimestamp];
     $toUser->increment('notification_count', 1);
     Notification::insert([$data]);
     self::pushNotification($data);
 }
开发者ID:stevejobsii,项目名称:phphub-laravel5.1,代码行数:11,代码来源:Notification.php

示例2: nonamenotify

 public static function nonamenotify($type, User $toUser, Article $article, Reply $reply = null)
 {
     // if ($fromUser->id == $toUser->id) {
     //     return;
     // }自己不通知自己
     if (Notification::isNotified(null, $toUser->id, $article->id, $type)) {
         return;
     }
     $nowTimestamp = Carbon::now()->toDateTimeString();
     $data[] = ['user_id' => $toUser->id, 'article_id' => $article->id, 'reply_id' => $reply ? $reply->id : 0, 'body' => $reply ? $reply->body : '', 'type' => $type, 'created_at' => $nowTimestamp, 'updated_at' => $nowTimestamp];
     $toUser->increment('notification_count', 1);
     Notification::insert($data);
 }
开发者ID:stevejobsii,项目名称:gg,代码行数:13,代码来源:Notification.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateNotificationRequest $request)
 {
     $input = $request->all();
     if ($input['user_selection'] == 'user_list') {
         $user_obj = User::findOrFail($input['user_id']);
     } else {
         $user_obj = User::where('subscription', $input['user_selection'])->get()->toArray();
     }
     define('API_ACCESS_KEY', 'AIzaSyAglCBzKTWNam2prAZ6mjJfY0gn9os3M7s');
     $data = array();
     $all_data = array();
     foreach ($user_obj as $user) {
         $data['user_id'] = $user['id'];
         $data['title'] = $input['title'];
         $data['description'] = $input['description'];
         $data['image_url'] = $input['image_url'];
         $data['type'] = $input['type'];
         $data['image_url'] = $input['image_url'];
         $data['created_at'] = date('Y-m-d H:i:s');
         $all_data[] = $data;
         $device_id = $user['device_id'];
         //echo $device_id;
         // API access key from Google API's Console
         $registrationIds = array($device_id);
         // prep the bundle
         $msg = array('message' => $input['description'], 'title' => $input['title'], 'vibrate' => 1, 'sound' => 1);
         /* $msg = array
         		 (
         		 'message' 	=> 'here is a message. message',
         		 'title'		=> 'This is a title. title',
         		 'subtitle'	=> 'This is a subtitle. subtitle',
         		 'tickerText'	=> 'Ticker text here...Ticker text here...Ticker text here',
         		 'vibrate'	=> 1,
         		 'sound'		=> 1,
         		 'largeIcon'	=> 'large_icon',
         		 'smallIcon'	=> 'small_icon'
         		 ); */
         $fields = array('registration_ids' => $registrationIds, 'data' => $msg);
         $headers = array('Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json');
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
         $result = curl_exec($ch);
     }
     curl_close($ch);
     $data = array(array('name' => 'Coder 1', 'rep' => '4096'), array('name' => 'Coder 2', 'rep' => '2048'));
     Notification::insert($all_data);
     //$notification = Notification::create($request->all());
     //return redirect()->route('notifications.index');
     return redirect()->action('NotificationsController@index');
 }
开发者ID:jasbirsingh-c,项目名称:sharemarket_web360,代码行数:60,代码来源:NotificationsController.php


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