mirror of
https://github.com/flarum/core.git
synced 2025-07-09 11:03:06 +02:00
[review] using orWhere to allow any where to follow in extensions
This commit is contained in:
committed by
Daniël Klabbers
parent
b150636906
commit
4adf342ce3
@ -100,9 +100,11 @@ class PostPolicy extends AbstractPolicy
|
|||||||
->whereColumn('discussions.id', 'posts.discussion_id')
|
->whereColumn('discussions.id', 'posts.discussion_id')
|
||||||
->where(function ($query) use ($actor) {
|
->where(function ($query) use ($actor) {
|
||||||
$query->whereRaw('1=0');
|
$query->whereRaw('1=0');
|
||||||
$this->events->dispatch(
|
$query->orWhere(function ($query) use ($actor) {
|
||||||
new ScopeModelVisibility(Discussion::query()->setQuery($query), $actor, 'hidePosts')
|
$this->events->dispatch(
|
||||||
);
|
new ScopeModelVisibility(Discussion::query()->setQuery($query), $actor, 'hidePosts')
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -117,7 +117,7 @@ class ShowDiscussionControllerTest extends ApiControllerTestCase
|
|||||||
$events = app(Dispatcher::class);
|
$events = app(Dispatcher::class);
|
||||||
|
|
||||||
$events->listen(ScopeModelVisibility::class, function (ScopeModelVisibility $event) {
|
$events->listen(ScopeModelVisibility::class, function (ScopeModelVisibility $event) {
|
||||||
$event->query->orWhereRaw('1=1');
|
$event->query->whereRaw('1=1');
|
||||||
});
|
});
|
||||||
|
|
||||||
$response = $this->callWith([], ['id' => 4]);
|
$response = $this->callWith([], ['id' => 4]);
|
||||||
|
Reference in New Issue
Block a user