public function run()
 {
     Promo::create(['link' => 'img/resources/promos/promo1.png', 'description' => '', 'speciality_id' => '5']);
     Promo::create(['link' => 'img/resources/promos/promo2.png', 'description' => '', 'speciality_id' => '5']);
     Promo::create(['link' => 'img/resources/promos/promo3.png', 'description' => '', 'speciality_id' => '24']);
     Promo::create(['link' => 'img/resources/promos/promo4.png', 'description' => '', 'speciality_id' => '2']);
 }
예제 #2
0
function addPromo()
{
    $promo = params("promo");
    $label = params("label");
    $newPromo = new Promo();
    $newPromo->setPromo($promo);
    $newPromo->setLabel($label);
    $status = $newPromo->create();
    set("status", $status);
    header('Content-Type: application/json');
    return render("status.json.php");
}
예제 #3
0
 public function create()
 {
     if (!$this->has_post()) {
         return redirect_message(array('admin', $this->get_class(), 'add'), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。'));
     }
     $posts = OAInput::post();
     $cover = OAInput::file('cover');
     if (!$cover) {
         return redirect_message(array('admin', $this->get_class(), 'add'), array('_flash_message' => '請選擇照片(gif、jpg、png)檔案,或提供照片網址!', 'posts' => $posts));
     }
     if ($msg = $this->_validation_posts($posts)) {
         return redirect_message(array('admin', $this->get_class(), 'add'), array('_flash_message' => $msg, 'posts' => $posts));
     }
     $posts['sort'] = Promo::count();
     $create = Promo::transaction(function () use($posts, $cover) {
         return verifyCreateOrm($promo = Promo::create(array_intersect_key($posts, Promo::table()->columns))) && $promo->cover->put($cover);
     });
     if (!$create) {
         return redirect_message(array('admin', $this->get_class(), 'add'), array('_flash_message' => '新增失敗!', 'posts' => $posts));
     }
     return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '新增成功!'));
 }