mirror of
https://github.com/flarum/framework.git
synced 2025-02-26 10:54:25 +08:00
[review] using orWhere to allow any where to follow in extensions
This commit is contained in:
parent
622e2a6644
commit
521834f5da
@ -98,9 +98,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')
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -115,7 +115,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]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user