1234567891011121314151617181920212223242526 |
- <?php
- namespace App\Http\Middleware;
- use App\Models\AppSession;
- use Closure;
- class EnsureCompanyClient
- {
- public function handle($request, Closure $next)
- {
- $patient = $request->route()->parameter('patient');
- if(!$patient) abort(403);
- if(!count($patient->companyClients)){
- return redirect()->to(route('patients.view.show-set-company-client', $patient));
- }
- $defaultCompanyClientUid = session()->get('DEFAULT_COMPANY_CLIENT_UID_'.@$patient->id);
- if(!$defaultCompanyClientUid){
- return redirect()->to(route('patients.view.show-set-default-company-client', $patient));
- }
- return $next($request);
- }
- }
|