From 4adf342ce33d14135fbe0c222c712cf85b0c95f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Tue, 19 Nov 2019 12:47:51 +0100 Subject: [PATCH] [review] using orWhere to allow any where to follow in extensions --- src/Post/PostPolicy.php | 8 +++++--- .../api/Controller/ShowDiscussionControllerTest.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Post/PostPolicy.php b/src/Post/PostPolicy.php index 46452eae4..358c5a899 100644 --- a/src/Post/PostPolicy.php +++ b/src/Post/PostPolicy.php @@ -100,9 +100,11 @@ class PostPolicy extends AbstractPolicy ->whereColumn('discussions.id', 'posts.discussion_id') ->where(function ($query) use ($actor) { $query->whereRaw('1=0'); - $this->events->dispatch( - new ScopeModelVisibility(Discussion::query()->setQuery($query), $actor, 'hidePosts') - ); + $query->orWhere(function ($query) use ($actor) { + $this->events->dispatch( + new ScopeModelVisibility(Discussion::query()->setQuery($query), $actor, 'hidePosts') + ); + }); }); }); }); diff --git a/tests/integration/api/Controller/ShowDiscussionControllerTest.php b/tests/integration/api/Controller/ShowDiscussionControllerTest.php index edda8999f..eb6b35146 100644 --- a/tests/integration/api/Controller/ShowDiscussionControllerTest.php +++ b/tests/integration/api/Controller/ShowDiscussionControllerTest.php @@ -117,7 +117,7 @@ class ShowDiscussionControllerTest extends ApiControllerTestCase $events = app(Dispatcher::class); $events->listen(ScopeModelVisibility::class, function (ScopeModelVisibility $event) { - $event->query->orWhereRaw('1=1'); + $event->query->whereRaw('1=1'); }); $response = $this->callWith([], ['id' => 4]);