Skip to content

Commit

Permalink
id and id not check query added
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Aug 25, 2024
1 parent 23512e4 commit f83743f
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/Repositories/Eloquent/AuditRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public function list(array $filters = [])
}
}

if (!empty($filters['id_not_in'])) {
$query->whereNotIn($this->model->getKeyName(), (array)$filters['id_not_in']);
}

if (!empty($filters['id_in'])) {
$query->whereIn($this->model->getKeyName(), (array)$filters['id_in']);
}

//Display Trashed
if (isset($filters['trashed']) && $filters['trashed'] === true) {
$query->onlyTrashed();
Expand Down
8 changes: 8 additions & 0 deletions src/Repositories/Eloquent/FavouriteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public function list(array $filters = [])
}
}

if (!empty($filters['id_not_in'])) {
$query->whereNotIn($this->model->getKeyName(), (array)$filters['id_not_in']);
}

if (!empty($filters['id_in'])) {
$query->whereIn($this->model->getKeyName(), (array)$filters['id_in']);
}

//Display Trashed
if (isset($filters['trashed']) && $filters['trashed'] === true) {
$query->onlyTrashed();
Expand Down
8 changes: 8 additions & 0 deletions src/Repositories/Eloquent/LoginAttemptRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public function list(array $filters = [])
$query->where('user_id', '=', $filters['user_id']);
}

if (!empty($filters['id_not_in'])) {
$query->whereNotIn($this->model->getKeyName(), (array)$filters['id_not_in']);
}

if (!empty($filters['id_in'])) {
$query->whereIn($this->model->getKeyName(), (array)$filters['id_in']);
}

//Handle Sorting
$query->orderBy($filters['sort'] ?? $this->model->getKeyName(), $filters['dir'] ?? 'asc');

Expand Down
8 changes: 8 additions & 0 deletions src/Repositories/Eloquent/PermissionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public function list(array $filters = [])
$query->onlyTrashed();
}

if (!empty($filters['id_not_in'])) {
$query->whereNotIn($this->model->getKeyName(), (array)$filters['id_not_in']);
}

if (!empty($filters['id_in'])) {
$query->whereIn($this->model->getKeyName(), (array)$filters['id_in']);
}

//Handle Sorting
$query->orderBy($filters['sort'] ?? $this->model->getKeyName(), $filters['dir'] ?? 'asc');

Expand Down
8 changes: 8 additions & 0 deletions src/Repositories/Eloquent/ProfileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public function list(array $filters = [])
$query->where('id_issue_country', '=', $filters['id_issue_country']);
}

if (!empty($filters['id_not_in'])) {
$query->whereNotIn($this->model->getKeyName(), (array)$filters['id_not_in']);
}

if (!empty($filters['id_in'])) {
$query->whereIn($this->model->getKeyName(), (array)$filters['id_in']);
}

//Display Trashed
if (isset($filters['trashed']) && $filters['trashed'] === true) {
$query->onlyTrashed();
Expand Down
12 changes: 9 additions & 3 deletions src/Repositories/Eloquent/RoleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ public function list(array $filters = [])
$query->where('team_id', '=', $filters['team_id']);
}

if (!empty($filters['id_not_in_array']) && is_array($filters['id_not_in_array'])) {
$query->whereNotIn('id', $filters['id_not_in_array']);
if (!empty($filters['id_not_in'])) {
$query->whereNotIn($this->model->getKeyName(), (array)$filters['id_not_in']);
}

if (!empty($filters['id_in'])) {
$query->whereIn($this->model->getKeyName(), (array)$filters['id_in']);
}

if (!empty($filters['name'])) {
Expand All @@ -62,7 +66,9 @@ public function list(array $filters = [])
$query->orderBy($filters['sort'] ?? $this->model->getKeyName(), $filters['dir'] ?? 'asc');

if (isset($filters['count_user']) && $filters['count_user'] === true) {
$query->withCount(['users']);
$query->groupBy('name')
->selectRaw('count(*) as count, name')
->count();
}

//Execute Output
Expand Down
8 changes: 8 additions & 0 deletions src/Repositories/Eloquent/TeamRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public function list(array $filters = [])
}
}

if (!empty($filters['id_not_in'])) {
$query->whereNotIn($this->model->getKeyName(), (array)$filters['id_not_in']);
}

if (!empty($filters['id_in'])) {
$query->whereIn($this->model->getKeyName(), (array)$filters['id_in']);
}

if (isset($filters['trashed']) && $filters['trashed'] === true) {
$query->onlyTrashed();
}
Expand Down
8 changes: 8 additions & 0 deletions src/Repositories/Eloquent/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public function list(array $filters = [])
$query->where($authField, '=', $filters[$authField]);
}

if (!empty($filters['id_not_in'])) {
$query->whereNotIn($this->model->getKeyName(), (array)$filters['id_not_in']);
}

if (!empty($filters['id_in'])) {
$query->whereIn($this->model->getKeyName(), (array)$filters['id_in']);
}

if (!empty($filters['user_id'])) {
$query->where($this->model->getKeyName(), '=', $filters['user_id']);
}
Expand Down

0 comments on commit f83743f

Please sign in to comment.