EnsureCompanyClient.php 451 B

123456789101112131415161718192021
  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. return $next($request);
  15. }
  16. }