EnsureCompanyClient.php 698 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Http\Middleware;
  3. use App\Models\AppSession;
  4. use Closure;
  5. class EnsureCompanyClient
  6. {
  7. public function handle($request, Closure $next)
  8. {
  9. $patient = $request->route()->parameter('patient');
  10. if(!$patient) abort(403);
  11. if(!count($patient->companyClients)){
  12. return redirect()->to(route('patients.view.show-set-company-client', $patient));
  13. }
  14. $defaultCompanyClientUid = session()->get('DEFAULT_COMPANY_CLIENT_UID_'.@$patient->id);
  15. if(!$defaultCompanyClientUid){
  16. return redirect()->to(route('patients.view.show-set-default-company-client', $patient));
  17. }
  18. return $next($request);
  19. }
  20. }