WorkMediaDao.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\work;
  12. use app\dao\BaseDao;
  13. use app\model\work\WorkMedia;
  14. /**
  15. * Class WorkMediaDao
  16. * @package app\dao\work
  17. */
  18. class WorkMediaDao extends BaseDao
  19. {
  20. /**
  21. * @return string
  22. */
  23. protected function setModel(): string
  24. {
  25. return WorkMedia::class;
  26. }
  27. /**
  28. * 删除时效的media_id
  29. * @return \crmeb\basic\BaseModel
  30. */
  31. public function deleteValidFile()
  32. {
  33. return $this->getModel()
  34. ->where('temporary', 1)
  35. ->where('valid_time', '<>', 0)
  36. ->where('valid_time', '<', time())
  37. ->update(['media_id' => '', 'valid_time' => 0]);
  38. }
  39. }