示例#1
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct($holder, $type, $item)
 {
     $this->holder = $holder;
     $notificationRepository = new NotificationRepository();
     if ($type == 'App\\Article') {
         $this->notification = $notificationRepository->article($item);
     } elseif ($type == 'App\\Post') {
         $this->notification = $notificationRepository->post($item);
     }
 }
示例#2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(MonitoredAddressRepository $monitored_address_repository, NotificationRepository $notification_respository, ConfirmationsBuilder $confirmations_builder, $addressId)
 {
     $monitored_address = $monitored_address_repository->findByUuid($addressId);
     if (!$monitored_address) {
         if (!$monitored_address) {
             return new JsonResponse(['message' => 'resource not found'], 404);
         }
     }
     // use the last notification for each txid
     $latest_notifications_by_txid = [];
     foreach ($notification_respository->findByMonitoredAddressId($monitored_address['id']) as $notification_model) {
         $notification = $notification_model['notification'];
         $key = $notification['txid'] . '-' . $notification['event'];
         if (isset($latest_notifications_by_txid[$key])) {
             if ($notification['confirmations'] > $latest_notifications_by_txid[$key]['confirmations']) {
                 $latest_notifications_by_txid[$key] = $notification;
             }
         } else {
             $latest_notifications_by_txid[$key] = $notification;
         }
     }
     $out = [];
     $current_block_height = $confirmations_builder->findLatestBlockHeight();
     foreach ($latest_notifications_by_txid as $raw_notification) {
         $notification = $raw_notification;
         // update the number of confirmations by block hash
         if (isset($raw_notification['bitcoinTx']['blockhash'])) {
             $confirmations = $confirmations_builder->getConfirmationsForBlockHashAsOfHeight($raw_notification['bitcoinTx']['blockhash'], $current_block_height);
         } else {
             $confirmations = 0;
         }
         $notification['confirmations'] = $confirmations;
         $notification['confirmed'] = $confirmations > 0 ? true : false;
         $out[] = $notification;
     }
     return json_encode($out);
 }
示例#3
0
 public function num(FriendRepository $friendRepository, NotificationRepository $notificationRepository)
 {
     return ['friend_request' => $friendRepository->requestsToMe()->count(), 'notification' => $notificationRepository->count()];
 }
示例#4
0
 public function notification(NotificationRepository $notificationRepository)
 {
     $notifications = $notificationRepository->notifications();
     return view('notifications.notifications', compact('notifications'));
 }