| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Http\Controllers\admin;
- use App\Http\Controllers\Controller;
- use App\Models\LhcNumber as LhcNumberModel;
- use Exception;
- use App\Constants\HttpStatus;
- class LhcNumber extends Controller
- {
- /**
- * 号码管理列表
- */
- public function list()
- {
- try {
- $list = LhcNumberModel::get();
- // 2. 格式化树形结构
- $tree = [];
-
- foreach ($list as $item) {
- // 一级节点:game
- if (!isset($tree[$item->game])) {
- $tree[$item->game] = [
- 'name' => $item->game,
- 'children' => []
- ];
- }
-
- // 二级节点:gameplay
- if (!isset($tree[$item->game]['children'][$item->gameplay])) {
- $tree[$item->game]['children'][$item->gameplay] = [
- 'name' => $item->gameplay,
- 'children' => []
- ];
- }
-
- // 三级:把数据放入 children
- $tree[$item->game]['children'][$item->gameplay]['children'][] = ['id' => $item->id,'number' => $item->number, 'odds' => $item->odds, 'maxinum' => $item->maxinum, 'mininum' => $item->mininum];
- }
-
- // 重新索引,返回纯数组结构
- $tree = array_values($tree);
- } catch (Exception $e) {
- return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
- }
- return $this->success([ 'data' => $tree]);
- }
- //设置赔率
- public function setOdds()
- {
- return $this->error(HttpStatus::CUSTOM_ERROR, '请前往赔率管理选择具体六合彩彩种和模板');
- }
- }
|