Group.php 1013 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php namespace Manage\Lib;
  2. use Dever;
  3. use Dever\Helper\Str;
  4. class Group extends Auth
  5. {
  6. public function getTree()
  7. {
  8. $data = Dever::db('group')->select([]);
  9. $result = array();
  10. $result[] = array
  11. (
  12. 'id' => 'root',
  13. 'name' => '全部集团',
  14. 'children' => $data,
  15. );
  16. return $result;
  17. }
  18. public function update($data)
  19. {
  20. if ($data['mobile']) {
  21. $database = '"2_' . $data['id'] . '"';
  22. $db = Dever::db('group_user', '', 'default', array('database' => $database));
  23. $info = $db->find(1);
  24. if (!$info) {
  25. $password = '123456';
  26. $insert['name'] = Str::hide($data['mobile']);
  27. $insert['mobile'] = $data['mobile'];
  28. $insert['role'] = 1;
  29. $insert += Dever::load('common')->createPwd($password);
  30. $db->insert($insert);
  31. }
  32. }
  33. }
  34. }