CertificateApply.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\common\model;
  10. use app\common\model\store\User;
  11. use think\db\Query;
  12. /**
  13. * Class CertificateApply
  14. *
  15. * @Author: Yeshihao
  16. * @DateTime: 2024/11/26 13:38
  17. * @package app\common\model
  18. */
  19. class CertificateApply extends BaseModel
  20. {
  21. protected $name = 'certificate_apply';
  22. protected $type = [
  23. 'certificate_ids' => 'array',
  24. 'result_data' => 'array',
  25. 'category_ids' => 'array',
  26. ];
  27. /**
  28. * [getStatusTextAttr]
  29. *
  30. * @Author: Yeshihao
  31. * @DateTime: 2024/11/28 10:06
  32. * @param $value
  33. * @param $data
  34. * @return string
  35. */
  36. public function getStatusTextAttr($value, $data)
  37. {
  38. $arr = [10 => '待审核', 20 => '审核通过', 30 => '审核失败'];
  39. return $arr[$data['status']] ?? '';
  40. }
  41. /**
  42. * [store]
  43. * 提交人
  44. *
  45. * @Author: Yeshihao
  46. * @DateTime: 2024/11/27 18:33
  47. * @return \think\model\relation\BelongsTo
  48. */
  49. public function storeUser()
  50. {
  51. return $this->belongsTo(User::class, 'store_user_id', 'store_user_id');
  52. }
  53. /**
  54. * [apply]
  55. * 申请人
  56. *
  57. * @Author: Yeshihao
  58. * @DateTime: 2024/11/27 18:33
  59. * @return \think\model\relation\BelongsTo
  60. */
  61. public function applyUser()
  62. {
  63. return $this->belongsTo(User::class, 'apply_user_id', 'store_user_id');
  64. }
  65. /**
  66. * 文章详情
  67. *
  68. * @param $id
  69. * @return null|static
  70. * @throws \think\exception\DbException
  71. */
  72. public static function detail($id)
  73. {
  74. return self::get($id);
  75. }
  76. /**
  77. * 软删除
  78. *
  79. * @return false|int
  80. */
  81. public function setDelete()
  82. {
  83. return $this->save(['is_delete' => 1]);
  84. }
  85. /**
  86. * [handlerSearch]
  87. *
  88. * @Author: Yeshihao
  89. * @DateTime: 2024/12/2 15:53
  90. * @param Query $query
  91. * @param array $param
  92. * @return Query
  93. */
  94. public function handlerSearch(Query $query, array $param)
  95. {
  96. //审核状态
  97. if (!empty($param['status'])) {
  98. $query->where('status', $param['status']);
  99. }
  100. //项目名称
  101. if (!empty($param['project'])) {
  102. $query->where('project', "like", "%{$param['project']}%");
  103. }
  104. return $query;
  105. }
  106. }