Skip to content

Commit

Permalink
Dynamically get the user's primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
thomastkim committed Nov 23, 2015
1 parent 0dfe5fa commit 5f6d4ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Kim/Activity/Scopes/ActivityOrderingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ protected function registerRelationshipOrderingQuery(Builder $query, Model $mode
$table = $model->getTable();

$userTable = config('auth.table');
$userModel = config('auth.model');
$userKey = (new $userModel)->getKeyName();

return $query->join($userTable, "{$table}.user_id", '=', "{$userTable}.id")->orderBy("{$userTable}.{$column}", $dir);
return $query->join($userTable, "{$table}.user_id", '=', "{$userTable}.{$userKey}")->orderBy("{$userTable}.{$column}", $dir);
};

$query->macro('orderByUsers', $macro);
Expand Down

0 comments on commit 5f6d4ba

Please sign in to comment.