Exemplo n.º 1
0
 public function getIndex()
 {
     $devices = Device::whereUserId(Auth::id())->orWhere(function ($query) {
         $authed_device_ids = DUAuth::whereUserId(Auth::id())->lists('device_id');
         $query->whereIn('id', $authed_device_ids);
     })->paginate(15);
     return View::make('device.index')->with('devices', $devices);
 }
Exemplo n.º 2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //如果还没有绑定任何设备,跳转到绑定设备页面
     if (Device::whereUserId(Auth::id())->count() == 0) {
         return Redirect::to('/device/bind')->withToast('请先绑定至少一台设备');
     }
     return $next($request);
 }
Exemplo n.º 3
0
 /**
  * 选择设备
  */
 public function getTarget()
 {
     $devices = Device::whereUserId(Auth::id())->orWhere(function ($query) {
         $authed_device_ids = DUAuth::whereUserId(Auth::id())->lists('device_id');
         $query->whereIn('id', $authed_device_ids);
     })->get();
     $response = View::make('install.target')->with('devices', $devices);
     if (Input::has('package')) {
         $package = Package::findOrFailFromArg(Input::get('package'), Auth::id());
         return $response->with('package', $package);
     } else {
         $url = Input::old('url');
         if (empty($url)) {
             return redirect('install')->withToast('发生异常');
         }
         return $response->with('url', $url);
     }
 }