<?php

namespace App\Http\Middleware;

use App\Models\AppSession;
use Closure;

class EnsureClientIsNotShadowOfPro
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $patient = \request()->route('patient');
        if(!!$patient) {
            if(!!$patient->shadow_pro_id) {
                abort(403);
            }
        }
        return $next($request);
    }
}
