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


PHP Notification::insert方法代码示例

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


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

示例1: notify

 public static function notify($type, User $fromUser, User $toUser, Topic $topic, Reply $reply = null)
 {
     if ($fromUser->id == $toUser->id) {
         return;
     }
     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);
 }
开发者ID:bobken,项目名称:phphub,代码行数:13,代码来源:Notification.php

示例2: NewTopicNotify

 public static function NewTopicNotify($type, User $fromUser, $users, Topic $topic)
 {
     $nowTimestamp = Carbon::now()->toDateTimeString();
     $data = [];
     foreach ($users as $toUser) {
         if ($fromUser->id == $toUser->id) {
             continue;
         }
         $data[] = ['from_user_id' => $fromUser->id, 'user_id' => $toUser->id, 'topic_id' => $topic->id, 'reply_id' => 0, 'body' => $topic->body, 'type' => $type, 'created_at' => $nowTimestamp, 'updated_at' => $nowTimestamp];
         $toUser->increment('notification_count', 1);
     }
     if (count($data)) {
         Notification::insert($data);
     }
     foreach ($data as $value) {
         self::pushNotification($value);
     }
 }
开发者ID:fcode520,项目名称:phphub,代码行数:18,代码来源:Notification.php

示例3: setUp

 /**
  * Set up for Vendor as well as guzzle/cookies
  **/
 public final function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "trier@cnm.edu";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $this->vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $this->vendor->insert($this->getPDO());
     $locationId = null;
     $description = "Front Stock";
     $storageCode = 12;
     $this->location = new Location($locationId, $storageCode, $description);
     $this->location->insert($this->getPDO());
     $unitId = null;
     $unitCode = "pk";
     $quantity = 10.5;
     $this->unitOfMeasure = new UnitOfMeasure($unitId, $unitCode, $quantity);
     $this->unitOfMeasure->insert($this->getPDO());
     $alertCode = "78";
     $alertFrequency = "56";
     $alertPoint = 1.4;
     $alertOperator = "A";
     $this->alertLevel = new AlertLevel(null, $alertCode, $alertFrequency, $alertPoint, $alertOperator);
     $this->alertLevel->insert($this->getPDO());
     $notificationId = null;
     $alertId = $this->alertLevel->getAlertId();
     $emailStatus = false;
     $notificationDateTime = null;
     $notificationHandle = "unit test";
     $notificationContent = "place holder";
     $notificationDateTime = DateTime::createFromFormat("Y-m-d H:i:s", "1985-06-28 04:26:03");
     $this->notification = new Notification($notificationId, $alertId, $emailStatus, $notificationDateTime, $notificationHandle, $notificationContent);
     $this->notification->insert($this->getPDO());
     // create and insert a GuzzleHttp
     $this->guzzle = new \GuzzleHttp\Client(['cookies' => true]);
 }
开发者ID:sandidgec,项目名称:foodinventory,代码行数:41,代码来源:product-api-test.php

示例4: register

    public static function register()
    {
        global $https, $store_home;
        $trigger = new Notification();
        Database::register_trigger($trigger);
        $dir = dirname($_SERVER['PHP_SELF']);
        if ($dir != '/') {
            $dir .= '/';
        }
        $protocol = $https ? 'https' : 'http';
        $url = "{$protocol}://{$_SERVER['HTTP_HOST']}{$dir}";
        Notification::$insert = <<<end
Your affiliate account has been credited with a new order.  The details are as
follows:
end;
        Notification::$update = <<<end
An order in your affiliate account has been changed.  The details are as
follows:
end;
        Notification::$signoff = <<<end
You are receiving this message because you signed up to be an affiliate of
{$store_home} .

If you no longer wish to receive these emails, you can turn them off by
visiting {$url} and clicking ‘Your Account’.
This will take you to a page where you can set your email preferences.

If you have any questions, please feel free to contact us at any time.
However, this email was sent from an address which is not monitored, so a reply
will not reach us.

Thank you for being a member of our affiliate programme.
end;
    }
开发者ID:JulioNavarro,项目名称:Affiliates-For-All,代码行数:34,代码来源:Notification.php

示例5: testGetValidAllNotifications

 /**
  * test grabbing all Notifications
  **/
 public function testGetValidAllNotifications()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("notification");
     // create a new notification and insert to into mySQL
     $notification = new Notification(null, $this->alertLevel->getAlertId(), $this->VALID_emailStatus, $this->VALID_notificationDateTime, $this->VALID_notificationHandle, $this->VALID_notificationContent);
     $notification->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoNotification = Notification::getAllNotifications($this->getPDO(), $this->VALID_notificationId);
     foreach ($pdoNotification as $note) {
         $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("notification"));
         $this->assertSame($note->getAlertId(), $this->alertLevel->getAlertId());
         $this->assertSame($note->getEmailStatus(), $this->VALID_emailStatus);
         $this->assertEquals($note->getNotificationDateTime(), $this->VALID_notificationDateTime);
         $this->assertSame($note->getNotificationHandle(), $this->VALID_notificationHandle2);
         $this->assertSame($note->getNotificationContent(), $this->VALID_notificationContent);
     }
 }
开发者ID:sandidgec,项目名称:foodinventory,代码行数:21,代码来源:notification-test.php

示例6: testGetValidProductByAlertId

 /**
  * test grabbing valid product by alertId
  **/
 public function testGetValidProductByAlertId()
 {
     // create a new notification and insert to into mySQL
     $newNotification = new Notification(null, $this->alertLevel->getAlertId(), $this->VALID_emailStatus, $this->VALID_notificationDateTime, $this->VALID_notificationHandle, $this->VALID_notificationContent);
     $newNotification->insert($this->getPDO());
     // grab the data from guzzle
     $response = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/notification/?alertId=' . $newNotification->getAlertId());
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $notification = json_decode($body);
     $this->assertSame(200, $notification->status);
 }
开发者ID:sandidgec,项目名称:foodinventory,代码行数:15,代码来源:notification-api-test.php

示例7: json_encode

                            }
                            $reply->data = $notifications;
                        } else {
                            throw new InvalidArgumentException("no parameters given", 405);
                        }
                    }
                }
            }
        }
        // post to a new Notification
    } else {
        if ($method === "POST") {
            // convert POSTed JSON to an object
            verifyXsrf();
            $requestContent = file_get_contents("php://input");
            $requestObject = json_decode($requestContent);
            $notificationDateTime = new DateTime();
            $notificationDateTime->setTimestamp($requestObject->notificationDateTime / 1000);
            $notification = new Notification(null, $requestObject->alertId, $requestObject->emailStatus, $requestObject->notificationDateTime, $requestObject->notificationHandle, $requestObject->notificationContent);
            $notification->insert($pdo);
            $reply->data = "Notification created OK";
        }
    }
    // create an exception to pass back to the RESTful caller
} catch (Exception $exception) {
    $reply->status = $exception->getCode();
    $reply->message = $exception->getMessage();
    unset($reply->data);
}
header("Content-type: application/json");
echo json_encode($reply);
开发者ID:sandidgec,项目名称:foodinventory,代码行数:31,代码来源:index.php


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