EnsureDefaultCompanyClient.php 563 B

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