From 3f86c725aadb913764392a1c4accfe45caea8a53 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 21 Oct 2018 21:31:15 +0800 Subject: [PATCH] Order user childs and siblings by birth_order --- app/User.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/User.php b/app/User.php index db7b068..cfdf3e2 100644 --- a/app/User.php +++ b/app/User.php @@ -104,10 +104,10 @@ class User extends Authenticatable public function childs() { if ($this->gender_id == 2) { - return $this->hasMany(User::class, 'mother_id'); + return $this->hasMany(User::class, 'mother_id')->orderBy('birth_order'); } - return $this->hasMany(User::class, 'father_id'); + return $this->hasMany(User::class, 'father_id')->orderBy('birth_order'); } public function profileLink($type = 'profile') @@ -206,7 +206,7 @@ class User extends Authenticatable } }) - ->get(); + ->orderBy('birth_order')->get(); } public function parent()