Browse Source

group users filter

tags/0.1.0
Robin Thoni 8 years ago
parent
commit
a2e01e299d

+ 2
- 2
src/Auth/Business/LuticateGroupsBusiness.php View File

25
         return $group;
25
         return $group;
26
     }
26
     }
27
 
27
 
28
-    public static function getUsers($group_id, $page = 0, $perPage = PHP_INT_MAX)
28
+    public static function getUsers($group_id, $page = 0, $perPage = PHP_INT_MAX, $query = "")
29
     {
29
     {
30
-        return LuticateGroupsDataAccess::getUsers($group_id, $page, $perPage);
30
+        return LuticateGroupsDataAccess::getUsers($group_id, $page, $perPage, $query);
31
     }
31
     }
32
 
32
 
33
     public static function getByName($group_name)
33
     public static function getByName($group_name)

+ 3
- 2
src/Auth/Controller/LuticateGroupsController.php View File

39
      * @param $group_id int The group id
39
      * @param $group_id int The group id
40
      * @param int $page The page number, 0 based
40
      * @param int $page The page number, 0 based
41
      * @param int $perPage The number of items per page
41
      * @param int $perPage The number of items per page
42
+     * @param string $query The filter query
42
      * @return \Luticate\Utils\LuMultipleDbo
43
      * @return \Luticate\Utils\LuMultipleDbo
43
      */
44
      */
44
-    public function getUsers($group_id, $page = 0, $perPage = PHP_INT_MAX)
45
+    public function getUsers($group_id, $page = 0, $perPage = PHP_INT_MAX, $query = "")
45
     {
46
     {
46
-        return LuticateGroupsBusiness::getUsers($group_id, $page, $perPage);
47
+        return LuticateGroupsBusiness::getUsers($group_id, $page, $perPage, $query);
47
     }
48
     }
48
 
49
 
49
     /**
50
     /**

+ 9
- 3
src/Auth/DataAccess/LuticateGroupsDataAccess.php View File

36
             return null;
36
             return null;
37
         return $group->toDbo();
37
         return $group->toDbo();
38
     }
38
     }
39
-    public static function getUsers($group_id, $page = 0, $perPage = PHP_INT_MAX)
39
+    public static function getUsers($group_id, $page = 0, $perPage = PHP_INT_MAX, $query = "")
40
     {
40
     {
41
-        $model = LuticateUsers::where("luticate_users_groups.group_id", "=", $group_id)
42
-            ->join("luticate_users_groups", "luticate_users.id", "=", "luticate_users_groups.user_id");
41
+        $model = LuticateUsers::where("luticate_users_groups.group_id", "=", $group_id);
42
+        if (!is_null($query) && $query != "") {
43
+            $model->where("luticate_users.username", "ilike", "%" . $query . "%")
44
+                ->where("luticate_users.email", "ilike", "%" . $query . "%")
45
+                ->where("luticate_users.firstname", "ilike", "%" . $query . "%")
46
+                ->where("luticate_users.lastname", "ilike", "%" . $query . "%");
47
+        }
48
+        $model->join("luticate_users_groups", "luticate_users.id", "=", "luticate_users_groups.user_id");
43
 
49
 
44
         $count = $model->count();
50
         $count = $model->count();
45
 
51
 

Loading…
Cancel
Save