Example #1
0
 public function index()
 {
     $user = Auth::user();
     if ($user->role == User::ROLE_ADMIN) {
         $devicesCount = Device::all()->count();
         $wxDevicesCount = WeixinDevice::all()->count();
         $appsCount = App::all()->count();
         $wxPagesCount = WeixinPage::all()->count();
     } else {
         $apps = App::where('user_id', $user->id)->lists('id');
         $devicesCount = DeviceApp::whereIn('app_id', $apps)->count();
         $mps = WeixinMp::whereIn('app_id', $apps)->lists('id');
         $wxDevicesCount = WeixinDevice::whereIn('wx_mp_id', $mps)->count();
         $appsCount = count($apps);
         $wxPagesCount = WeixinPage::whereIn('wx_mp_id', $mps)->count();
     }
     return view('admin.index')->with('devicesCount', $devicesCount)->with('wxDevicesCount', $wxDevicesCount)->with('appsCount', $appsCount)->with('wxPagesCount', $wxPagesCount);
 }