1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-03 07:26:49 +08:00
koogua cbc2e5762a !11 阶段性合并
* 根据app需要作出相应调整
* 路由增加命名name,增加app应用管理
* 完成基本API,增加h5和小程序支付定义
2020-11-10 10:25:16 +08:00

127 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Models;
use App\Caches\MaxCategoryId as MaxCategoryIdCache;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class AppVersion extends Model
{
/**
* 平台类型
*/
const PLATFORM_IOS = 1;
const PLATFORM_ANDROID = 2;
/**
* 主键编号
*
* @var int
*/
public $id;
/**
* 平台类型
*
* @var int
*/
public $platform;
/**
* 版本名例如v1.0.0
*
* @var string
*/
public $version_name;
/**
* 版本号例如100
*
* @var string
*/
public $version_code;
/**
* 下载地址
*
* @var string
*/
public $download_url;
/**
* 发布标识
*
* @var int
*/
public $published;
/**
* 删除标识
*
* @var int
*/
public $deleted;
/**
* 创建时间
*
* @var int
*/
public $create_time;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public function getSource(): string
{
return 'kg_category';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();
}
public function beforeUpdate()
{
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
public function afterCreate()
{
$cache = new MaxCategoryIdCache();
$cache->rebuild();
}
public static function types()
{
return [
self::TYPE_COURSE => '课程',
self::TYPE_HELP => '帮助',
];
}
}