コード例 #1
0
 public function afterValidation(&$data)
 {
     $ex = DBWOGPlayerTeam::find($data['m_id']);
     if ($data['pkval'] && $ex && $data['pkval'] != $data['m_id']) {
         Response::alert("ID重複");
     }
     foreach ([1, 2, 3, 4, 5] as $n) {
         if ($data["skill_{$n}"] > 0) {
             $s = DBWOGSkill::find($data["skill_{$n}"]);
             if (!$s) {
                 Response::alert("技能{$n}(s_id={$data["skill_{$n}"]})不存在");
             }
         }
     }
     if ($data['d_id']) {
         foreach (explode(',', $data['d_id']) as $d_id) {
             $d = DBWOGItem::find($d_id);
             if (!$d) {
                 Response::alert("道具(d_id={$d_id})不存在");
             }
         }
     }
     if ($data['m_mission'] > 0) {
         $m = DBWOGMission::find($data['m_mission']);
         if (!$m) {
             Response::alert("任務(m_id={$data['m_mission']})不存在");
         }
     }
 }
コード例 #2
0
 public function afterValidation(&$data)
 {
     $item = DBWOGItem::find($data['d_id']);
     if (!$item) {
         Response::alert("物品(d_id={$data['d_id']})不存在");
     }
     $stone = DBWOGItemKey::with('item')->find($data['d_id']);
     if ($stone && $data['d_id'] != $data['pkval']) {
         Response::alert("{$stone->item->d_name}(d_id={$data['d_id']})已有定義,不可重複定義");
     }
 }
コード例 #3
0
 public function afterValidation(&$data)
 {
     $item = DBWOGItem::find($data['item_id']);
     if (!$item) {
         Response::alert("物品(item_id={$data['item_id']})不存在");
     }
     $item = DBWOGItemHonor::where('item_Id', '=', $data['item_id'])->with('item')->get();
     if (count($item) > 0 && (!$data['pkval'] || $data['pkval'] != $item[0]->h_id)) {
         Response::alert("{$item[0]->item->d_name}(d_id={$data['item_id']})已有定義,不可重複定義");
     }
 }
コード例 #4
0
 public function afterValidation(&$data)
 {
     $player = DBWOGPlayer::find($data['p_id']);
     if (!$player) {
         Response::alert("拍賣玩家(p_id={$data['p_id']})不存在");
     }
     if ($data['e_p_id'] > 0) {
         $eplayer = DBWOGPlayer::find($data['e_p_id']);
         if (!$eplayer) {
             Response::alert("競標玩家(p_id={$data['e_p_id']})不存在");
         }
     }
     $item = DBWOGItem::find($data['d_id']);
     if (!$item) {
         Response::alert("拍賣物品(d_id={$data['d_id']})不存在");
     }
     $sale = DBWOGItemSale::find($data['s_id']);
     if ($data['pkval'] && $sale && $data['pkval'] != $data['s_id']) {
         Response::alert("ID重複");
     }
 }
コード例 #5
0
 public function show()
 {
     $page = Input::get("page");
     $rows = Input::get("rows");
     $sort = Input::get("sort", App::make($this->dbname)->getKeyName());
     $order = Input::get("order", 'ASC');
     $table = 'wog_syn';
     $alias = 'ds';
     $prefix = $alias . '.';
     switch ($sort) {
         case 'd_name':
             $prefix = 'd.';
             break;
     }
     $list = ['total' => call_user_func(array($this->dbname, 'count')), 'rows' => call_user_func(array($this->dbname, 'from'), $table . ' AS ' . $alias)->leftJoin('wog_df AS d', $alias . '.syn_result', '=', 'd.d_id')->orderBy($prefix . $sort, $order)->skip(($page - 1) * $rows)->take($rows)->get([$alias . '.*', 'd.d_name'])];
     //整理要抓出的d_id
     $ids = [];
     $idmap = [];
     $elements = [];
     foreach ($list['rows'] as $k => $row) {
         $data = preg_split('/[\\*\\,]/i', $row['syn_element']);
         $temp = [];
         for ($i = 0, $len = count($data); $i < $len; $i += 2) {
             $ids[] = $data[$i];
             $idmap[$data[$i]][] = [$k, floor($i / 2)];
             $temp[] = $data[$i + 1];
         }
         $elements[] = $temp;
     }
     $items = DBWOGItem::whereIn('d_id', array_unique($ids))->get();
     foreach ($items as $k => $item) {
         foreach ($idmap[$item->d_id] as $map) {
             $elements[$map[0]][$map[1]] = $item->d_name . '*' . $elements[$map[0]][$map[1]];
         }
     }
     foreach ($elements as $k => $element) {
         $list['rows'][$k]['syn_name'] = implode(', ', $element);
     }
     return Response::json($list);
 }
コード例 #6
0
 public function show()
 {
     $page = Input::get("page");
     $rows = Input::get("rows");
     $sort = Input::get("sort", App::make($this->dbname)->getKeyName());
     $order = Input::get("order", 'ASC');
     $list = ['total' => call_user_func(array($this->dbname, 'count')), 'rows' => call_user_func(array($this->dbname, 'leftJoin'), 'wog_player', 'wog_item.p_id', '=', 'wog_player.p_id')->orderBy('wog_item.' . $sort, $order)->skip(($page - 1) * $rows)->take($rows)->get(['wog_item.*', 'wog_player.p_name'])];
     $rowmap = [];
     $keys = ['a_id' => 'a_name', 'd_head_id' => 'head_name', 'd_body_id' => 'body_name', 'd_hand_id' => 'hand_name', 'd_foot_id' => 'foot_name', 'd_item_id' => 'item_name', 'd_key_id' => 'key_name', 'd_honor_id' => 'honor_name', 'd_stone_id' => 'stone_name', 'd_plus_id' => 'plus_name'];
     $ids = [];
     $map = [];
     $temp = [];
     //整理&歸納
     foreach ($list['rows'] as $index => $row) {
         $temp[$index] = [];
         foreach ($keys as $key => $resultname) {
             $temp[$index][$resultname] = [];
             if (!$row[$key]) {
                 //沒資料直接跳過
                 continue;
             }
             $sanitized = preg_replace('/[\\:\\&]\\d+/', '', $row[$key]);
             if (strstr($sanitized, '*') !== FALSE) {
                 //有數量
                 $frag = preg_split('/[\\,\\*]/', $sanitized);
                 for ($i = 0, $len = count($frag); $i < $len; $i += 2) {
                     $ids[] = $frag[$i];
                     if (!isset($map[$frag[$i]])) {
                         //初始化
                         $map[$frag[$i]] = [];
                     }
                     $map[$frag[$i]][] = [$index, $resultname, count($temp[$index][$resultname])];
                     $temp[$index][$resultname][] = $frag[$i + 1];
                 }
             } else {
                 //沒數量
                 $frag = explode(',', $sanitized);
                 foreach ($frag as $id) {
                     $ids[] = $id;
                     if (!isset($map[$id])) {
                         //初始化
                         $map[$id] = [];
                     }
                     $map[$id][] = [$index, $resultname, count($temp[$index][$resultname])];
                     $temp[$index][$resultname][] = 1;
                 }
             }
         }
     }
     //Response::alert(var_export($ids, true));
     //送出查詢
     $items = DBWOGItem::whereIn('d_id', array_unique($ids))->get();
     //映射
     foreach ($items as $item) {
         foreach ($map[$item->d_id] as $entry) {
             $temp[$entry[0]][$entry[1]][$entry[2]] = $item->d_name . '*' . $temp[$entry[0]][$entry[1]][$entry[2]];
         }
     }
     //重建
     foreach ($temp as $index => $data1) {
         foreach ($data1 as $name => $result) {
             $list['rows'][$index][$name] = implode(', ', $result);
         }
     }
     return Response::json($list);
 }