added email notifications on expense approved/rejected (whatsapp tmr)
This commit is contained in:
@@ -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,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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user