added email notifications on expense approved/rejected (whatsapp tmr)

This commit is contained in:
Jagad R R
2024-12-24 15:12:24 +07:00
parent 6dc23422ed
commit 0030c0f48e
21 changed files with 1627 additions and 13 deletions
+27
View File
@@ -77,4 +77,31 @@ class Admin extends Authenticatable
}
return $hasPermission;
}
public function getCabangAndRegionHead()
{
// Fetch the UserHasCabang entry for this admin
$userHasCabang = $this->hasOne(UserHasCabang::class, 'user_id')->with('cabang')->first();
if ($userHasCabang && $userHasCabang->cabang) {
$cabang = $userHasCabang->cabang;
// Fetch the cabang head
$cabangHead = $cabang->head;
// Fetch the region and its head
$region = $cabang->region;
$regionHead = $region ? $region->head : null;
return [
'cabang_head' => $cabangHead,
'region_head' => $regionHead,
];
}
return [
'cabang_head' => null,
'region_head' => null,
];
}
}