From 97a94a8c603e73353194670695de47ed4c7088f5 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 21 Jul 2018 17:21:37 +0930 Subject: [PATCH] Specify ambiguous column names --- framework/core/src/Discussion/DiscussionPolicy.php | 6 +++--- framework/core/src/Post/PostPolicy.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/core/src/Discussion/DiscussionPolicy.php b/framework/core/src/Discussion/DiscussionPolicy.php index d59e37637..d2bbd74f1 100644 --- a/framework/core/src/Discussion/DiscussionPolicy.php +++ b/framework/core/src/Discussion/DiscussionPolicy.php @@ -92,7 +92,7 @@ class DiscussionPolicy extends AbstractPolicy if (! $actor->hasPermission('discussion.hide')) { $query->where(function ($query) use ($actor) { $query->whereNull('discussions.hidden_at') - ->orWhere('user_id', $actor->id) + ->orWhere('discussions.user_id', $actor->id) ->orWhere(function ($query) use ($actor) { $this->events->fire( new ScopeModelVisibility($query, $actor, 'hide') @@ -105,8 +105,8 @@ class DiscussionPolicy extends AbstractPolicy // current user, or the user is allowed to edit the discussion's posts. if (! $actor->hasPermission('discussion.editPosts')) { $query->where(function ($query) use ($actor) { - $query->where('comment_count', '>', 0) - ->orWhere('user_id', $actor->id) + $query->where('discussions.comment_count', '>', 0) + ->orWhere('discussions.user_id', $actor->id) ->orWhere(function ($query) use ($actor) { $this->events->dispatch( new ScopeModelVisibility($query, $actor, 'editPosts') diff --git a/framework/core/src/Post/PostPolicy.php b/framework/core/src/Post/PostPolicy.php index 0370e775c..162343101 100644 --- a/framework/core/src/Post/PostPolicy.php +++ b/framework/core/src/Post/PostPolicy.php @@ -82,7 +82,7 @@ class PostPolicy extends AbstractPolicy if (! $actor->hasPermission('discussion.editPosts')) { $query->where(function ($query) use ($actor) { $query->whereNull('posts.hidden_at') - ->orWhere('user_id', $actor->id) + ->orWhere('posts.user_id', $actor->id) ->orWhereExists(function ($query) use ($actor) { $query->selectRaw('1') ->from('discussions')