123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace ln\services;
- use EasyWeChat\Support\Collection;
- use EasyWeChat\User\Group;
- use FormBuilder\Exception\FormBuilderException;
- use FormBuilder\Factory\Elm;
- use FormBuilder\Form;
- use think\facade\Route;
- /**
- * Class WechatUserGroupService
- * @package ln\services
- * @author xaboy
- * @day 2020-04-27
- */
- class WechatUserGroupService
- {
- /**
- * @var Group
- */
- protected $userGroup;
- /**
- * WechatTemplateService constructor.
- */
- public function __construct()
- {
- $this->userGroup = WechatService::create()->getApplication()->user_group;
- }
- /**
- * @return Group
- * @author xaboy
- * @day 2020-04-29
- */
- public function userGroup()
- {
- return $this->userGroup;
- }
- /**
- * @return array
- * @author xaboy
- * @day 2020-04-27
- */
- public function lst()
- {
- return $this->userGroup->lists()->toArray();
- }
- /**
- * @param $groupName
- * @return Collection
- * @author xaboy
- * @day 2020-04-27
- */
- public function create($groupName)
- {
- return $this->userGroup->create($groupName);
- }
- /**
- * @param $id
- * @param $groupName
- * @return Collection
- * @author xaboy
- * @day 2020-04-27
- */
- public function update($id, $groupName)
- {
- return $this->userGroup->update($id, $groupName);
- }
- /**
- * @param $id
- * @return Collection
- * @author xaboy
- * @day 2020-04-27
- */
- public function delete($id)
- {
- return $this->userGroup->delete($id);
- }
- /**
- * @param null $id
- * @param string $name
- * @return Form
- * @throws FormBuilderException
- * @author xaboy
- * @day 2020-04-27
- */
- public function form($id = null, $name = '')
- {
- return Elm::createForm($id ? Route::buildUrl('updateWechatUserGroup', compact('id'))->build() : Route::buildUrl('createWechatUserGroup')->build(), [
- Elm::input('tag_name', '分组名称', $name)->required()
- ])->setTitle($id ? '编辑用户分组' : '添加用户分组');
- }
- }
|