fix data not showing in some role
This commit is contained in:
@@ -30,7 +30,7 @@ class FormUpCountryController extends Controller
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
$forms = FormUpCountry::get();
|
||||
|
||||
if ($role == 'Admin Region') {
|
||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||
|
||||
if ($region_id) {
|
||||
@@ -42,8 +42,20 @@ class FormUpCountryController extends Controller
|
||||
$forms = $forms->whereIn('user_id', $userIds);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if ($role == 'Area Manager Cabang') {
|
||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||
|
||||
if ($cabang_id) {
|
||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
||||
$userIds = $users->pluck('user_id')->toArray();
|
||||
$forms = $forms->whereIn('user_id', $userIds);
|
||||
}
|
||||
}
|
||||
else if ($role == 'Medical Representatif') {
|
||||
$forms = $forms->where('user_id', auth()->user()->id);
|
||||
}
|
||||
else {
|
||||
$forms = $forms;
|
||||
}
|
||||
|
||||
session()->put('redirect_url', route('forms.up-country'));
|
||||
|
||||
Reference in New Issue
Block a user