Commit 0b89476d authored by rlgy's avatar rlgy

平台(不要写死)

parent d4506c9f
...@@ -48,7 +48,8 @@ class CoinController extends BaseController ...@@ -48,7 +48,8 @@ class CoinController extends BaseController
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
return $data; return $data;
} }
return $this->render('index'); $platforms = Coin::getPlatformList();
return $this->render('index', ['platforms' => $platforms]);
} }
public function actionAdd() public function actionAdd()
......
...@@ -32,7 +32,9 @@ ...@@ -32,7 +32,9 @@
<div class="layui-input-inline"> <div class="layui-input-inline">
<select name="platform"> <select name="platform">
<option value="all">全部</option> <option value="all">全部</option>
<option value="ethereum">eth</option> <?php foreach ($platforms as $platform): ?>
<option value="<?= $platform ?>"><?= $platform ?></option>
<?php endforeach; ?>
</select> </select>
</div> </div>
</div> </div>
......
...@@ -98,4 +98,16 @@ class Coin extends BaseActiveRecord ...@@ -98,4 +98,16 @@ class Coin extends BaseActiveRecord
{ {
return $this->hasOne(MinerFee::className(), ['platform' => 'platform']); return $this->hasOne(MinerFee::className(), ['platform' => 'platform']);
} }
/**
* 获取平台列表
*
* @return array
*/
public static function getPlatformList()
{
$data = self::find()->select('platform')->asArray()->all();
$data = array_unique(array_column($data, 'platform'));
return $data;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment