name = $params['name']; $userLable->remark = $params['remark']; $userLable->label_type = $params['label_type']; $userLable->save(); return true; } /** * @notes 标签详情 * @param int $id * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author cjhao * @date 2021/7/28 17:58 */ public function detail(int $id) { return UserLabel::field('id,name,remark,label_type')->find($id)->toArray(); } /** * @notes 编辑用户标签 * @param array $params * @return bool * @author cjhao * @date 2021/7/28 17:47 */ public function edit(array $params) { $updateData = [ 'id' => $params['id'], 'name' => $params['name'], 'remark' => $params['remark'], 'label_type' => $params['label_type'], ]; UserLabel::update($updateData); return true; } /** * @notes 删除标签 * @param int $ids * @return bool * @author cjhao * @date 2021/7/28 18:36 */ public function del(array $ids) { UserLabel::destroy($ids); UserLabelIndex::where(['label_id'=>$ids])->delete(); return UserLabel::destroy($ids); } }