<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;
class CheckActivePlan
{
    public function handle($request, Closure $next)
    {
        if (Auth::user()->investActive()->count() == 0) {
            $notify[] = ['warning', 'Buy a plan at first!'];
            return to_route('user.home')->withNotify($notify);
        }
        return $next($request);
    }
}
