12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\services\work;
- use app\services\other\CategoryServices;
- use crmeb\services\FormBuilder;
- use think\exception\ValidateException;
- class WorkChannelCategoryServices extends CategoryServices
- {
- const TYPE = 4;
-
- public function getCateList(array $where = [], array $field = ['*'], array $with = [])
- {
- $where['group'] = self::TYPE;
- $where['owner_id'] = 0;
- return parent::getCateList($where, $field, $with);
- }
-
- public function getCateAll(int $group = self::TYPE, int $storeId = 0)
- {
- return $this->dao->getCateList(['type' => 0, 'owner_id' => 0, 'relation_id' => $storeId, 'group' => $group]);
- }
-
- public function cateForm(array $cataData = [])
- {
- $f[] = FormBuilder::input('name', '分类名称', $cataData['name'] ?? '')->maxlength(20)->required();
- $f[] = FormBuilder::number('sort', '排序', (int)($cataData['sort'] ?? 0))->min(0);
- return $f;
- }
-
- public function createForm()
- {
- return create_form('添加渠道二维码分类', $this->cateForm(), $this->url('/work/channel/cate'), 'POST');
- }
-
- public function updateForm(int $id)
- {
- $cate = $this->dao->get($id);
- if (!$cate) {
- throw new ValidateException('渠道二维码分类没有查到');
- }
- return create_form('编辑渠道二维码分类', $this->cateForm($cate->toArray()), $this->url('work/channel/cate/' . $id), 'PUT');
- }
- }
|