fix data not showing in some role
This commit is contained in:
@@ -31,7 +31,7 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormEntertaimentPresentation::get();
|
$forms = FormEntertaimentPresentation::get();
|
||||||
|
|
||||||
if ($role == 'Admin Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
@@ -43,9 +43,21 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$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);
|
$forms = $forms->where('user_id', auth()->user()->id);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$forms = $forms;
|
||||||
|
}
|
||||||
|
|
||||||
session()->put('redirect_url', route('forms.entertainment'));
|
session()->put('redirect_url', route('forms.entertainment'));
|
||||||
return view('backend.pages.forms.entertainment.index', [
|
return view('backend.pages.forms.entertainment.index', [
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class FormMeetingSeminarController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormMeetingSeminar::get();
|
$forms = FormMeetingSeminar::get();
|
||||||
|
|
||||||
if ($role == 'Admin Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
@@ -43,9 +43,21 @@ class FormMeetingSeminarController extends Controller
|
|||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$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);
|
$forms = $forms->where('user_id', auth()->user()->id);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$forms = $forms;
|
||||||
|
}
|
||||||
|
|
||||||
session()->put('redirect_url', route('forms.meeting'));
|
session()->put('redirect_url', route('forms.meeting'));
|
||||||
return view('backend.pages.forms.meeting.index', [
|
return view('backend.pages.forms.meeting.index', [
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class FormOtherController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormOthers::get();
|
$forms = FormOthers::get();
|
||||||
|
|
||||||
if ($role == 'Admin Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
@@ -46,9 +46,21 @@ class FormOtherController extends Controller
|
|||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$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);
|
$forms = $forms->where('user_id', auth()->user()->id);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$forms = $forms;
|
||||||
|
}
|
||||||
|
|
||||||
session()->put('redirect_url', route('forms.other'));
|
session()->put('redirect_url', route('forms.other'));
|
||||||
return view('backend.pages.forms.other.index', [
|
return view('backend.pages.forms.other.index', [
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class FormUpCountryController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormUpCountry::get();
|
$forms = FormUpCountry::get();
|
||||||
|
|
||||||
if ($role == 'Admin Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
@@ -42,9 +42,21 @@ class FormUpCountryController extends Controller
|
|||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$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);
|
$forms = $forms->where('user_id', auth()->user()->id);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$forms = $forms;
|
||||||
|
}
|
||||||
|
|
||||||
session()->put('redirect_url', route('forms.up-country'));
|
session()->put('redirect_url', route('forms.up-country'));
|
||||||
return view('backend.pages.forms.upcountry.index', [
|
return view('backend.pages.forms.upcountry.index', [
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class FormVehicleController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormVehicleRunningCost::get();
|
$forms = FormVehicleRunningCost::get();
|
||||||
|
|
||||||
if ($role == 'Admin Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
@@ -42,9 +42,21 @@ class FormVehicleController extends Controller
|
|||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$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);
|
$forms = $forms->where('user_id', auth()->user()->id);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$forms = $forms;
|
||||||
|
}
|
||||||
|
|
||||||
session()->put('redirect_url', route('forms.vehicle'));
|
session()->put('redirect_url', route('forms.vehicle'));
|
||||||
return view('backend.pages.forms.vehicle.index', [
|
return view('backend.pages.forms.vehicle.index', [
|
||||||
|
|||||||
Reference in New Issue
Block a user