-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Add) Allow internal options for internals in non-internal group #4370
(Add) Allow internal options for internals in non-internal group #4370
Conversation
PR Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!
Can we use $user->internals()->exists()
instead to make it more efficient?
Further, I think we can even drop the is_internal
column on the groups
table and use this relation as the source of truth instead for all cases the is_internal
flag is checked. What do you think @HDVinnie?
No,
I'll let this up to you, and think it should be going into its own PR. |
LGTM. Just swap the count for exist. |
db660a3
to
37ec70c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using loadExists
, you need to specify the relation to load, i.e. ->loadExists('internals')
. Then, instead of checking for if $user->internals()->exists()
, you only have to check the $user->internals_exists
property that's added to the user without needing further database calls.
Added this to the APIController, but Larastan doesn't seem to like it... |
I checked through the larastan repo and you're right: unfortunately larastan doesn't yet support relation_exists (although it does support relation_count). Try adding |
16913aa
to
2f24c6a
Compare
3513b49
to
f3bb4f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do a ctrl+f in your IDE for ->group->is_internal
and replace all the instances with the ->internals()->exists()
logic? (And use eager loading if the query is used multiple times in a single http request).
Thanks!
5cf51c2
to
a9c2494
Compare
0adb474
to
eaee5c6
Compare
Internals that are not member of the internal group (e.g. Editor) but not Moderator+ should still be able to set the internal options on their uploads. Also, replace all group->is_internal with internals->exists in app & views.
eaee5c6
to
ba1818b
Compare
Thank you! |
Internals that are not member of the internal group (e.g., Editor) and not Moderator+ should still be able to set the internal options on their uploads. They need to be in at least one Internal group, checked using count of
InternalUsers
.