app/Models/User.php: sort main characters first for "characters" relationship.
This commit is contained in:
parent
3f7d29ce79
commit
77e8792edc
1 changed files with 7 additions and 1 deletions
|
|
@ -69,7 +69,13 @@ class User extends Authenticatable
|
|||
|
||||
public function characters()
|
||||
{
|
||||
return $this->hasMany(Character::class);
|
||||
$relation = $this->hasMany(Character::class);
|
||||
|
||||
// sort main character first if set.
|
||||
if ($this->character_id) {
|
||||
$relation->orderByRaw('id = ' . $this->character_id . ' DESC');
|
||||
}
|
||||
return $relation;
|
||||
}
|
||||
|
||||
public function getRoleAttribute()
|
||||
|
|
|
|||
Reference in a new issue