public function create() { if (!$this->has_post()) { return redirect_message(array($this->get_class()), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。')); } $posts = OAInput::post(); if ($msg = $this->_validation_posts($posts)) { return redirect_message(array($this->get_class()), array('_flash_message' => $msg, 'posts' => $posts)); } $contact = null; $create = Contact::transaction(function () use($posts, &$contact) { return verifyCreateOrm($contact = Contact::create(array_intersect_key($posts, Contact::table()->columns))); }); if (!($create && $contact)) { return redirect_message(array($this->get_class()), array('_flash_message' => '新增失敗,系統可能在維修,請稍候再嘗試一次!', 'posts' => $posts)); } delay_job('contacts', 'mail', array('id' => $contact->id)); return redirect_message(array($this->get_class()), array('_flash_message' => '新增成功,已經收到您的建議,我們會儘快回覆您!')); }
public function delay() { delay_job('main', 'index', array('sec' => 5)); }