From 569ac93c7d03702fa0541665558dd7e841b4adee Mon Sep 17 00:00:00 2001 From: Isaac Machakata Date: Mon, 1 Apr 2024 19:34:54 +0200 Subject: [PATCH] refactor: add get users function --- app/Models/Account.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Models/Account.php b/app/Models/Account.php index 535d2ae..a6dfeef 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -43,4 +43,16 @@ class Account extends Model protected $afterFind = []; protected $beforeDelete = []; protected $afterDelete = []; + + /** + * Returns an array of employees and their departments 6 at a time + * + * @return array|null + */ + public function getUsers() + { + return $this->join('employees', 'AccountID = accounts.ID') + ->join('departments', 'DepartmentID = departments.ID') + ->paginate(6); + } }