EnsureCompanyClient.php 589 B

12345678910111213141516171819202122232425
  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. $params = [
  13. 'patient' => $patient,
  14. 'popupmode' => request()->input('popupmode')
  15. ];
  16. return redirect()->to(route('patients.view.show-set-company-client', $params));
  17. }
  18. return $next($request);
  19. }
  20. }