page($get['page'], $get['limit'])->select()->toArray(); return ['count' => $count, 'lists' => $lists]; } public static function add($post) { try{ $userLevel = BusinessTeam::where(['name'=>trim($post['name'])])->findOrEmpty(); if(!$userLevel->isEmpty()) { throw new \think\Exception('名称已被使用,请更换后重试'); } $time = time(); $data = [ 'name' => trim($post['name']), 'phone' => trim($post['phone']), 'create_time' => $time, ]; BusinessTeam::create($data); return true; }catch(\Exception $e) { self::$error = $e->getMessage(); return false; } } public static function edit($post) { try{ $userLevel = BusinessTeam::where([ ['name', '=', trim($post['name'])], ['id', '<>', $post['id']] ])->findOrEmpty(); if(!$userLevel->isEmpty()) { throw new \think\Exception('名称已被使用,请更换后重试'); } $data = [ 'id' => $post['id'], 'name' => trim($post['name']), 'phone' => trim($post['phone']), ]; BusinessTeam::update($data); return true; }catch(\Exception $e) { self::$error = $e->getMessage(); return false; } } public static function del($id) { try{ BusinessTeam::where('id', $id)->delete(); return true; }catch(\Exception $e) { self::$error = $e->getMessage(); return false; } } public static function getBusinessTeamList() { $levelArr = BusinessTeam::field('id,name,phone') ->order('id desc') ->select() ->toArray(); return $levelArr; } public static function getBusinessTeam($id){ $detail = BusinessTeam::where(['id'=>$id])->findOrEmpty(); if($detail->isEmpty()) { return []; } $detail = $detail->toArray(); return $detail; } }