-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Added created_by to users #11383
Added created_by to users #11383
Conversation
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
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.
This looks GREAT! I had a tiny stylistic nit but you could totally ignore me and it wouldn't bother me much. Very thorough, and I do like the custom scope you used for the ordering - clever, and clean.
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
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.
I think createdBy
and CreatedBy()
methods both existing is gonna be confusing :(
One other nonsense comment I threw in that you should ignore.
@@ -705,7 +705,7 @@ public function scopeOrderDepartment($query, $order) | |||
* | |||
* @return \Illuminate\Database\Query\Builder Modified query builder | |||
*/ | |||
public function scopeOrderAdmin($query, $order) | |||
public function scopeCreatedBy($query, $order) |
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.
Should this be scopeOrderCreatedBy()
?
@@ -67,7 +67,7 @@ public function index(Request $request) | |||
'users.remote', | |||
'users.ldap_import', | |||
|
|||
])->with('manager', 'groups', 'userloc', 'company', 'department', 'assets', 'licenses', 'accessories', 'consumables', 'adminuser',) | |||
])->with('manager', 'groups', 'userloc', 'company', 'department', 'assets', 'licenses', 'accessories', 'consumables', 'createdBy',) |
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.
This is a silly aesthetic thing, but it's weird that we don't normally use snakeCase and here is the one place where we do. But, that's the Laravel convention and we probably ought to follow it, so this is probably exactly how it should be.
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.
Duly ignored :P
Thank you for reviewing :) |
I am frankly shocked that I didn't have this on the user's table before - seems like a real boner move TBH - everything else in the system records who created the thing, but we somehow missed it 9 years ago and never noticed. (To be fair, nobody asked for it, but still... weird that I'd have missed something so obvious.)
Anyway... this adds a DB column called
created_by
to the users table. It is important to note that this is a divergence from our standard convention. We typically use the (very confusing) field nameuser_id
to denote the Snipe-IT user id of the person who created the thing - but since it's confusing, I will be changing that over time to use a more commoncreated_by
, so it's clearer what that field means. I didn't want to include that in this PR though, since it's a breaking change to the API.In the user view blade, we check to see if that admin has been (soft) deleted, and if it has, we strike it through. If not, we link to the person who created the user.
The API payload is standard for what we return for users, managers, etc.