OwlCyberSecurity - MANAGER
Edit File: InvestmentMiddleware.php
<?php namespace App\Http\Middleware; use App\Sportpesa\Modules\User\Model\User; use Carbon\Carbon; use Closure; class InvestmentMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (currentUser() && currentUser()->subscription_status=='1'){ if (currentUser()->next_due_date<=Carbon::now()->format('Y-m-d H:i:s')){ User::where('id', currentUser()->id)->update(['subscription_status'=>'0']); } } if (currentUser()->subscription_status=='0') { if (currentUser()->sub_count=='0') { $request->session()->flash("error", "YOU NEED TO SUBSCRIBE TO ACCESS THIS VIP STORE <br> <span class='text-red'>PLEASE PICK A PLAN BELOW</span>"); } else { $plan = strtoupper(currentUser()->sub->category); $duration = strtoupper(currentUser()->sub->accessTime); $date = strtoupper(Carbon::parse(currentUser()->next_due_date)->diffForHumans()); $request->session()->flash("error", "SORRY, YOUR CURRENT SUBSCRIPTION TO PLAN <strong style='color: darkgreen'>$plan VIP PLAN</strong> OF <strong>$duration</strong> HAS EXPIRED <strong style='color: darkred'>$date</strong> <br> <span class='text-red'>PLEASE PICK ANOTHER PLAN BELOW</span>"); } return redirect('/vip'); } elseif (currentUser()->sub->category=='Investment') return $next($request); else { $request->session()->flash("error", "YOUR SUBSCRIPTION PACKAGE CANNOT ACCESS THIS <strong>VIP STORE</strong>"); return redirect('/vip'); } } }