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,
];
}
}
+11
View File
@@ -11,9 +11,20 @@ class Cabang extends Model
protected $table = 'cabang';
protected $fillable = [
'head_id',
'region_id',
'cost_id',
'code',
'name',
];
public function head()
{
return $this->belongsTo(Admin::class, 'head_id');
}
public function region()
{
return $this->belongsTo(Region::class, 'region_id');
}
}
+6
View File
@@ -11,7 +11,13 @@ class Region extends Model
protected $table = 'region';
protected $fillable = [
'head_id',
'code',
'name',
];
public function head()
{
return $this->belongsTo('App\Models\Admin');
}
}