IndexController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. *
  4. * @author Mike <m@9026.com>
  5. * @version 1.0
  6. * @date 2015年10月12日
  7. *
  8. */
  9. namespace App\Http\Controllers\Admin\Base;
  10. use App\Http\Controllers\Admin\Controller;
  11. use App\Services\Base\Tree;
  12. use App\Services\Base\BaseArea;
  13. use App\Services\Admin\Menus;
  14. use App\Services\Admin\Acl;
  15. class IndexController extends Controller
  16. {
  17. public function __construct()
  18. {
  19. parent::__construct();
  20. }
  21. function index() {
  22. if($this->_user['is_root']) {
  23. $obj = new Menus();
  24. $menus = $obj->search(array('level'=>2,'display'=>1),$orderby=array('sort'=>'desc'),$pagesize = 100000);
  25. $menus = $menus->toArray();
  26. $menus = list_to_tree($menus['data']);
  27. }else{
  28. $obj = new Acl();
  29. $data = $obj->getRoleMenu($this->_user['admin_role_id']);
  30. $menus = list_to_tree($data);
  31. }
  32. return view('admin.base.index.index',compact('menus'));
  33. }
  34. function welcome() {
  35. return view('admin.base.index.welcome');
  36. }
  37. function createAreaDate(){
  38. //Base-index-createareadate.do
  39. header("Content-type:text/html;charset=utf-8");
  40. $areaObj = new BaseArea();
  41. $data = $areaObj->getLevel();
  42. $treeObj = new Tree();
  43. $treeObj -> init($data);
  44. $info = $treeObj -> getTree();
  45. $output = array();
  46. foreach($info AS $key => $val){
  47. if($val['id'] == '100000') continue;
  48. $val['level'] = $val['level'] - 1;
  49. unset($val['grade'], $val['spacer']);
  50. $output[]= $val;
  51. }
  52. $str = json_encode($output);
  53. $area_path = public_path() . '/base/js/areadata.js';
  54. file_put_contents($area_path, $str);
  55. echo $str;exit;
  56. }
  57. }