public function handle($request, Closure $next, $guard = null)
{
if (!Auth::guard($guard)->guest()) {
if ($this->hasCookie('a_p')) {
return $next($request);
} else {
$AccountPlan = \App\User::GetUserSubscriptionType();
if (!$AccountPlan) {
$user_diff = \App\User::IfUserTrial();
if ($user_diff) {
$AccountPlan['plan_id'] = 'trial';
$AccountPlan['days_left'] = $user_diff;
} else {
$AccountPlan['plan_id'] = false;
}
}
$this->makeMyCookie();
return $next($request);
}
}
}
protected function makeMyCookie($AccountPlan)
{
return Cookie::queue(Cookie::make('a_p', $AccountPlan, 129600));
}
protected function hasCookie($cookie_name)
{
$cookie_exist = Cookie::get($cookie_name);
return ($cookie_exist) ? true : false;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community