Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. +<?php
  2. +
  3. +namespace App\Http\Controllers\v2;
  4. +
  5. +use App\Http\Controllers\Controller;
  6. +use App\Repositories\RepDataRepository;
  7. +use App\Helpers\RepDashboard\DoctorRepDashboardTemplate;
  8. +use App\Helpers\RepDashboard\PharmacyRepDashboardTemplate;
  9. +
  10. +
  11. +class RepWidgetController extends Controller
  12. +{
  13. +
  14. +
  15. + /**
  16. + * @return array
  17. + * @throws \Exception
  18. + */
  19. + public function index()
  20. + {
  21. + $user = auth()->user();
  22. + $repository = new RepDataRepository($user);
  23. +
  24. + if ($user->job_title_c === 'Doctor_Only_Rep') {
  25. + $repDashboardTemplate = new DoctorRepDashboardTemplate();
  26. +
  27. + return $repDashboardTemplate->getData($repository);
  28. + }
  29. +
  30. + if ($user->job_title_c === 'Sales_Rep') {
  31. + $repDashboardTemplate = new PharmacyRepDashboardTemplate();
  32. +
  33. + return $repDashboardTemplate->getData($repository);
  34. + }
  35. +
  36. + return response()->json([
  37. + 'error' => 'Rep is not a pharmacy or doctor rep'
  38. + ], 403);
  39. + }
  40. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement