Version.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\api\model;
  3. use think\Model;
  4. use traits\model\SoftDelete;
  5. class Version extends Model
  6. {
  7. use SoftDelete;
  8. // 表名
  9. protected $name = 'app_version';
  10. // 自动写入时间戳字段
  11. protected $autoWriteTimestamp = 'int';
  12. // 定义时间戳字段名
  13. protected $createTime = 'create_time';
  14. protected $updateTime = 'update_time';
  15. protected $deleteTime = 'delete_time';
  16. // 追加属性
  17. protected $append = [];
  18. /**
  19. * 获取最新版本信息
  20. * @param string $version 当前版本号
  21. * @param string $platform 系统记录的最新版本号
  22. * @return array|bool|false|\PDOStatement|string|Model
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. * @author fuyelk <fuyelk@fuyelk.com>
  27. */
  28. public static function getLatest($version, $platform)
  29. {
  30. $lastVersion = self::field('version,content,download_file,enforce')->where('platform', $platform)->order('id', 'desc')->find();
  31. if (empty($lastVersion)) {
  32. return false;
  33. }
  34. return $lastVersion;
  35. }
  36. }