初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\config;
|
||||
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Config;
|
||||
class Vod extends Model
|
||||
{
|
||||
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
public function getList(){
|
||||
return Config::get('vod');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态
|
||||
* @param $name
|
||||
* @param $status
|
||||
* @return void
|
||||
*/
|
||||
public function setStatus($name,$status = true){
|
||||
$config = $this->getList();
|
||||
|
||||
foreach ($config as &$item){
|
||||
if($status == true){
|
||||
if($item['status']== 1){
|
||||
//禁用
|
||||
// \app\admin\controller\Addon::selfstate($item['type'],'disable');
|
||||
$item['status'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if($item['type'] == $name){
|
||||
$item['status'] = $status ? 1 : 0;
|
||||
|
||||
if($item['status'] == 1){
|
||||
// \app\admin\controller\Addon::selfstate($item['type'],'enable');
|
||||
}
|
||||
}
|
||||
}
|
||||
$configFile = CONF_PATH . 'extra' . DS . 'vod.php';
|
||||
|
||||
file_put_contents($configFile, '<?php' . "\n\nreturn " . var_export_short($config) . ";\n");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取选中的平台
|
||||
* @return false|mixed
|
||||
*/
|
||||
public static function getChecked(){
|
||||
$config = Config::get('vod');
|
||||
|
||||
foreach ($config as $item){
|
||||
if($item['status']){
|
||||
return $item['type'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user