Skip to content

Commit df7d0c3

Browse files
author
Mateus Junges
committed
1 parent aeaba37 commit df7d0c3

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to `mateusjunges/laravel-acl` will be documented in this file.
44

5+
## 2.1.1
6+
- Fixed bug with the `group` scope. See [#133](https://github.com/mateusjunges/laravel-acl/issues/133)
7+
58
## 2.1.0
69
- Update dependencies for Laravel 6
710
- Drop support for Laravel 5.5 and older, and PHP 7.1 and older. (They can use v2.0 of this package until they upgrade.)

src/Traits/UsersTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ public function scopeGroup(Builder $query, $groups) : Builder
512512
return $query->whereHas('groups', function ($query) use ($groups) {
513513
$query->where(function ($query) use ($groups) {
514514
foreach ($groups as $group) {
515-
if (is_null($group)) {
515+
if (! is_null($group)) {
516516
$query->orWhere(config('acl.tables.groups').'.id', $group->id);
517517
}
518518
}

tests/Traits/UsersTrait/ScopeGroupTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function test_it_should_return_only_users_with_the_specified_group()
2323
{
2424
$this->testUser->assignGroup('test-user-group');
2525
$this->testUser2->assignGroup('test-user-group');
26+
$this->testUser3->assignGroup($this->testUserGroup2);
2627
self::assertFalse(
2728
User::group('test-user-group')
2829
->get()
@@ -38,6 +39,8 @@ public function test_it_should_return_only_users_with_the_specified_group()
3839
->get()
3940
->contains('name', $this->testUser2->name)
4041
);
42+
self::assertCount(2, User::group('test-user-group')->get());
43+
self::assertCount(1, User::group($this->testUserGroup2)->get());
4144
}
4245

4346
public function test_if_it_thrown_an_exception_if_the_group_does_not_exist_using_group_slug()

0 commit comments

Comments
 (0)