| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /**
- *
- * @copyright ©2020 点小铺
- * @author hanj
- * @link: https://dyuit.com
- * Created by VSCode
- */
- namespace app\store\model;
- use app\common\model\CertificateCategory as CertificateCategoryModel;
- use app\store\model\Certificate as CertificateModel;
- class CertificateCategory extends CertificateCategoryModel
- {
- /**
- * [getALL]
- * 获取全部资质分类
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 14:19
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public static function getALL()
- {
- $model = new static;
- return $model->where('is_delete', 0)->order(['create_time' => 'asc'])->select()->toArray();
- }
- /**
- * [add]
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 14:22
- * @param $data
- * @return false|int
- */
- public function add($data)
- {
- $data['wxapp_id'] = self::$wxapp_id;
- return $this->allowField(true)->save($data);
- }
- /**
- * [edit]
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/26 14:27
- * @param $data
- * @return false|int
- */
- public function edit($data)
- {
- return $this->allowField(true)->save($data);
- }
- /**
- * 删除商品分类
- *
- * @param $category_id
- * @return bool|int
- */
- public function remove($category_id)
- {
- // 判断是否存在文章
- $count = CertificateModel::getCertificateTotal(['certificate_category_id' => $category_id]);
- if ($count > 0) {
- $this->error = '该分类下存在'.$count.'个文章,不允许删除';
- return false;
- }
- return $this->delete();
- }
- }
|