From b8cf5e550f6fac04cf6174c5a44a995fb51d5ded Mon Sep 17 00:00:00 2001 From: Sholahuddin Al Ayubi Date: Thu, 11 Dec 2025 17:22:45 +0700 Subject: [PATCH] refactor(branch): clean up formatting and structure in Branch model --- app/Models/Branch.php | 82 +++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/app/Models/Branch.php b/app/Models/Branch.php index 5d828fa..c4955ed 100644 --- a/app/Models/Branch.php +++ b/app/Models/Branch.php @@ -1,43 +1,49 @@ belongsTo(Branch::class, 'parent_id'); - } - - /** - * Get the child branches of this branch - */ - public function children() - { - return $this->hasMany(Branch::class, 'parent_id'); - } + return $this->belongsTo(Branch::class, 'parent_id'); } + + /** + * Get the child branches of this branch + */ + public function children() + { + return $this->hasMany(Branch::class, 'parent_id'); + } + + + public function users() + { + return $this->belongsToMany(Modules\Usermanagement\Models\User::class, 'user_branches', 'branch_id', 'user_id'); + } +}