Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +<?php
- +
- +namespace App\Http\Controllers\v2;
- +
- +use App\Http\Controllers\Controller;
- +use App\Repositories\RepDataRepository;
- +use App\Helpers\RepDashboard\DoctorRepDashboardTemplate;
- +use App\Helpers\RepDashboard\PharmacyRepDashboardTemplate;
- +
- +
- +class RepWidgetController extends Controller
- +{
- +
- +
- + /**
- + * @return array
- + * @throws \Exception
- + */
- + public function index()
- + {
- + $user = auth()->user();
- + $repository = new RepDataRepository($user);
- +
- + if ($user->job_title_c === 'Doctor_Only_Rep') {
- + $repDashboardTemplate = new DoctorRepDashboardTemplate();
- +
- + return $repDashboardTemplate->getData($repository);
- + }
- +
- + if ($user->job_title_c === 'Sales_Rep') {
- + $repDashboardTemplate = new PharmacyRepDashboardTemplate();
- +
- + return $repDashboardTemplate->getData($repository);
- + }
- +
- + return response()->json([
- + 'error' => 'Rep is not a pharmacy or doctor rep'
- + ], 403);
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement