Exemplo n.º 1
0
 /**
  * Named scope for customer users
  * @param unknown $query
  */
 public function scopeCustomer($query)
 {
     $query->leftJoin('user_to_role', 'user.id', '=', 'user_to_role.user_id');
     $query->leftJoin('role', 'role.id', '=', 'user_to_role.role_id');
     $query->groupBy('user.id');
     return $query->where('role.value', '=', 'role_customer');
 }
Exemplo n.º 2
0
 /**
  *
  * @param unknown $query
  */
 public function scopePopular($query)
 {
     return $query->where('votes', '>', 100);
 }
Exemplo n.º 3
0
 /**
  * Named scope for customer category
  * @param unknown $query
  */
 public function scopeCustomer($query)
 {
     return $query->where('permission.category', '=', 'customer');
 }
Exemplo n.º 4
0
 /**
  * Named scope for geting custom features only
  * @param unknown $query
  */
 public function scopeCustom($query)
 {
     return $query->where('system', '=', 0);
 }
Exemplo n.º 5
0
 /**
  * Query scope for filtering admin users
  * @param unknown $query
  */
 public function scopeAdmin($query)
 {
     $id = \DB::table('user_group')->where(['name' => 'admin'])->value('id');
     return $query->where('user_group_pk_id', '=', $id);
 }
Exemplo n.º 6
0
 /**
  * Query scope for filtering admins
  * @param unknown $query
  */
 public function scopeUser($query)
 {
     return $query->where('name', '=', 'user');
 }
Exemplo n.º 7
0
 /**
  * Method for the create where commands for filter function
  *
  * @param unknown $query
  * @param unknown $db
  * @return string where command for audiotrack list filtering
  */
 public function setFilters($query, $db)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     // Filter by Artist / Band.
     if ($artist = $app->getUserStateFromRequest('filter.artist', 'filter_artist')) {
         $query->where('a.artist = "' . $db->escape($artist) . '"');
     }
     // Filter by Category.
     if ($category_id = $app->getUserStateFromRequest('filter.category_id', 'filter_category_id')) {
         $query->where('a.catid = ' . (int) $category_id);
     }
     // Filter by Category.
     if ($access_id = $app->getUserStateFromRequest('filter.access_id', 'filter_access_id')) {
         $query->where('a.access = ' . (int) $access_id);
     }
     // Filter by User.
     if ($user_id = $app->getUserStateFromRequest('filter.user_id', 'filter_user_id')) {
         $query->where('a.add_by = ' . (int) $user_id);
     }
     // Filter by Album.
     if ($album = $app->getUserStateFromRequest('filter.album', 'filter_album')) {
         $query->where('a.album = "' . $db->escape($album) . '"');
     }
     // Filter by Year.
     if ($year = $app->getUserStateFromRequest('filter.year', 'filter_year')) {
         $query->where('a.year = ' . (int) $year);
     }
     // Filter by User.
     if (JAccess::check($user->get('id'), 'core.admin') != 1) {
         $query->where('a.add_by = ' . $user->get('id'));
     }
     return $query;
 }
Exemplo n.º 8
0
 /**
  * Query scope for filtering prirmary contact number
  * @param unknown $query
  */
 public function scopePrimary($query)
 {
     return $query->where('primary', '=', '1');
 }
Exemplo n.º 9
0
 /**
  * Named scope for protected navs
  * @param unknown $query
  */
 public function scopeProtected($query)
 {
     return $query->where('navigation.protected', '=', 1);
 }
Exemplo n.º 10
0
 /**
  * Chỉ hiện thị các bài viết (Article) đã lựa chọn cho phép hiển thị
  * 
  * @param unknown $query
  */
 public function scopeActive($query)
 {
     $query->where('status', 1);
 }
Exemplo n.º 11
0
 /**
  * Named scope for geting inactive roles only
  * @param unknown $query
  */
 public function scopeInactive($query)
 {
     return $query->where('active', '=', 0);
 }