Exemplo n.º 1
0
 /**
  * show Users Lists
  */
 public function getLists($filters = array(), $paginateItems = 50)
 {
     $items = $this->buildFilterWithElementsQuery($filters, "\\Veer\\Models\\UserList")->orderBy('name', 'asc')->orderBy('created_at', 'desc')->with('user', 'elements')->with($this->loadSiteTitle())->paginate($paginateItems);
     list($itemsRegroup, $itemsUsers) = $this->iterateLists($items);
     $items['regrouped'] = isset($itemsRegroup) ? $itemsRegroup : array();
     $items['users'] = isset($itemsUsers) ? $itemsUsers : array();
     $items['basket'] = \Veer\Models\UserList::where('name', '=', '[basket]')->count();
     $items['lists'] = \Veer\Models\UserList::where('name', '!=', '[basket]')->count();
     return $items;
 }
Exemplo n.º 2
0
 /**
  * Query Builder: 
  * 
  * - who: Items Quantity
  * - with: 
  * - to whom: add2cart(), user.login | user/cart/add
  */
 public function getUserLists($siteId, $userid, $sessionid = null, $name = "[basket]", $onlySum = true)
 {
     $items = \Veer\Models\UserList::where('sites_id', '=', $siteId)->where(function ($query) use($userid, $sessionid) {
         if ($userid > 0) {
             $query->where('users_id', '=', empty($userid) ? 0 : $userid)->orWhere('session_id', '=', $sessionid);
         } else {
             $query->where('users_id', '=', empty($userid) ? 0 : $userid)->where('session_id', '=', $sessionid);
         }
     })->where('name', '=', $name);
     if ($name == "[basket]") {
         $items->where('elements_type', '=', 'Veer\\Models\\Product');
     }
     return $onlySum == true ? $items->sum('quantity') : $items;
 }
Exemplo n.º 3
0
 /**
  * delete List
  * @todo relations
  */
 protected function deleteList($id)
 {
     \Veer\Models\UserList::where('id', '=', $id)->delete();
     return true;
 }
Exemplo n.º 4
0
 /**
  * Login Post
  */
 public function loginPost()
 {
     $save_old_session_id = \Session::getId();
     if (\Auth::attempt(array('email' => \Input::get('email'), 'password' => \Input::get('password'), 'banned' => 0, 'sites_id' => app('veer')->siteId))) {
         \Auth::user()->increment('logons_count');
         \Session::put('roles_id', \Auth::user()->roles_id);
         \Veer\Models\UserList::where('session_id', '=', $save_old_session_id)->update(array('users_id' => \Auth::id()));
         \Session::put('shopping_cart_items', $this->showUser->getUserLists(app('veer')->siteId, \Auth::id(), app('session')->getId()));
         if (administrator() == true) {
             \Veer\Models\UserAdmin::where('id', '=', app('veer')->administrator_credentials['id'])->update(array("sess_id" => \Session::getId(), "last_logon" => now(), "ips" => \Illuminate\Support\Facades\Request::getClientIp(), "logons_count" => app('veer')->administrator_credentials['logons_count'] + 1));
         }
         return \Redirect::intended();
     }
     return $this->login();
     // @todo withErrors()
 }