Ejemplo n.º 1
0
 public function getResults($filter = null)
 {
     $renderedRewards = [];
     $rewards = Reward::isActive();
     $user = Auth::getUser();
     switch ($filter) {
         case 'qty':
             $rewards->where('inventory', '>', 0);
             break;
         case 'time':
             $rewards->whereNotNull('date_begin');
             $rewards->whereNotNull('date_end');
             break;
         case 'bookmarked':
             $rewards->whereHas('bookmarks', function ($query) use($user) {
                 $query->where('user_id', '=', $user->id);
             });
             break;
         case 'all':
         default:
             $rewards->whereIn('id', function ($query) {
                 $query->select('id')->from(with(new Reward())->getTable())->whereNull('inventory')->orWhere('inventory', '>', 0);
             })->whereIn('id', function ($query) {
                 $query->select('id')->from(with(new Reward())->getTable())->whereNull('date_begin')->whereNull('date_end');
             })->whereIn('id', function ($query) {
                 $query->select('id')->from(with(new Reward())->getTable())->where('date_begin', '<=', date('c'))->where('date_end', '>=', date('c'))->where('is_published', '>', 0)->where('inventory', '>', 0);
             }, 'or');
             break;
     }
     $rewards = $rewards->orderBy('points')->paginate($this->property('limit'));
     foreach ($rewards as $reward) {
         $renderedRewards[] = ['rendered' => View::make('dma.friends::rewardPreview', ['reward' => $reward, 'user' => $user, 'allowRedeem' => LocationManager::enableAction()])->render(), 'id' => $reward->id];
     }
     return ['links' => $rewards->render(), 'rewards' => $renderedRewards];
 }
Ejemplo n.º 2
0
 /**
  * Resource to login user via barcode scanner for authorized kiosks
  */
 public static function barcodeLogin()
 {
     $barcodeId = get('barcodeId');
     $barcodeId = trim($barcodeId);
     $location = LocationManager::getLocation();
     if (!$location || empty($barcodeId)) {
         return Redirect::to('/');
     }
     if ($location->is_authorized) {
         $data = ['login' => $barcodeId, 'no_password' => true];
         AuthManager::auth($data);
     }
     return Redirect::to('/');
 }
 public function onAuthRegister($user)
 {
     // Print the reward if user is at a kiosk
     $location = LocationManager::getLocation();
     if ($location) {
         $printManager = new PrintManager($location, $user);
         $printManager->printIdCard();
     }
     // Process Activity for registration
     Registration::process($user);
 }
Ejemplo n.º 4
0
 /**
  * Render the login form.  Override the partial "login-form" 
  * in the active theme to customize the login form
  */
 public function onLogin()
 {
     return $this->renderPartial('@modalDisplay', ['title' => Lang::get('dma.friends::lang.userLogin.loginTitle'), 'content' => $this->renderPartial('login-form', ['enableAction' => LocationManager::enableAction()])]);
 }
Ejemplo n.º 5
0
 public function onRun()
 {
     $this->page['showForm'] = LocationManager::enableAction();
 }