本文整理匯總了PHP中History::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP History::create方法的具體用法?PHP History::create怎麽用?PHP History::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類History
的用法示例。
在下文中一共展示了History::create方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveHistoryAction
public function saveHistoryAction()
{
if ($this->request->isPost() == true) {
$request = json_decode(file_get_contents("php://input"));
$history = new History();
$history->history_string = $request->string;
$history->create() == false ? $this->response->setStatusCode(403, 'Server Error') : $this->response->setStatusCode(201, 'OK');
} else {
$this->response->setStatusCode(403, 'Bad request');
}
}
示例2: sendMail
private static function sendMail($curr_uid, $matched_uid, $restaurant_id)
{
$user1 = User::find($curr_uid);
$user2 = User::find($matched_uid);
//Add to User1's history
History::create(['uid' => $curr_uid, 'matched_id' => $matched_uid, 'restaurant_id' => $restaurant_id]);
//Add to User2's history
History::create(['uid' => $matched_uid, 'matched_id' => $curr_uid, 'restaurant_id' => $restaurant_id]);
$email_data1 = array('recipient' => $user1->email, 'subject' => 'Congratulations! We found you a match!');
$view_data1 = ['email' => $user2->email, 'gender' => $user2->gender, 'restaurant' => $restaurant_id];
Mail::send('emails.match', $view_data1, function ($message) use($email_data1) {
$message->to($email_data1['recipient'])->subject($email_data1['subject']);
});
$email_data2 = array('recipient' => $user2->email, 'subject' => 'Congratulations! We found you a match!');
$view_data2 = ['email' => $user1->email, 'gender' => $user1->gender, 'restaurant' => $restaurant_id];
Mail::send('emails.match', $view_data2, function ($message) use($email_data2) {
$message->to($email_data2['recipient'])->subject($email_data2['subject']);
});
return true;
}