| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- /**
- *
- * @copyright ©2020 点小铺
- * @author hanj
- * @link: https://dyuit.com
- * Created by VSCode
- */
- namespace app\store\model;
- use app\common\model\Certificate as CertificateModel;
- /**
- * Class Certificate
- * 资质管理
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 14:01
- * @package app\store\model
- */
- class Certificate extends CertificateModel
- {
- public function getList()
- {
- return $this->with(['file', 'category'])
- ->where('is_delete', '=', 0)
- ->order(['create_time' => 'desc'])
- ->paginate(15, false, [
- 'query' => request()->request()
- ]);
- }
- /**
- * [add]
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 14:55
- * @param $data
- * @return false|int
- */
- public function add($data)
- {
- if (empty($data['file_id'])) {
- $this->error = '请上传资质文件';
- return false;
- }
- if (empty($data['name'])) {
- $this->error = '请输入资质名称';
- return false;
- }
- //获取文件类型
- $file = UploadFile::detail($data['file_id']);
- $data['file_type'] = $file['file_type'];
- $data['wxapp_id'] = self::$wxapp_id;
- return $this->allowField(true)->save($data);
- }
- /**
- * 更新记录
- *
- * @param $data
- * @return bool|int
- */
- public function edit($data)
- {
- if (empty($data['file_id'])) {
- $this->error = '请上传资质文件';
- return false;
- }
- if (empty($data['name'])) {
- $this->error = '请输入资质名称';
- return false;
- }
- return $this->allowField(true)->save($data) !== false;
- }
- /**
- * [getCertificateTotal]
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 14:31
- * @param array $where
- * @return int|string
- * @throws \think\Exception
- */
- public static function getCertificateTotal($where = [])
- {
- $model = new static;
- !empty($where) && $model->where($where);
- return $model->where('is_delete', '=', 0)->count();
- }
- }
|