| // +------------------------------------------------+ namespace app\common\service; use app\common\model\Team as TeamModel; use app\common\validate\Team as TeamValidate; class Team extends _Init { /** * 添加信息 * @param [type] $data 团队数据 */ public static function create($data) { $validate = new TeamValidate(); if (!$validate->scene('add')->check($data)) { return $validate->getError(); } $info = TeamModel::create($data); if ($info) { return true; } else { return '创建团队失败'; } } /** * 编辑团队 * @param [type] $data 更新的数据 * @return [type] 返回 修改的结果 */ public static function edit($data) { $validate = new TeamValidate(); if (!$validate->scene('add')->check($data)) { return $validate->getError(); } $info = TeamModel::update($data); if ($info) { return true; } else { return '编辑团队失败'; } } /** * 修改团队状态 * @param [type] $id 团队id * @param [type] $status 状态 * @return [type] 返回结果 */ public static function status($id, $status) { $info = TeamModel::get($id); if (!$info) { return '团队不存在'; } elseif ($info->save(['status' => $status])) { return true; } else { return '修改状态失败'; } } /** * 删除团队 * @param [type] $id 要删除的团队id * @return [type] 返回 结果 */ public static function del($id) { $info = TeamModel::get($id); if (!$info) { return '团队不存在'; // } elseif ($info->save(['status' => -1])) { } elseif ($info->destroy($id)) { return true; } else { return '删除失败'; } // $model = new TeamModel(); // if ($model->destroy($id)) { // return true; // } else { // return '删除失败'; // } } }