menu

Questions & Answers

How to check if user is subscribed to stripe's plan (Laravel Cashier)

here is my Middleware

<?php

namespace App\Http\Middleware;

use Closure;

class CheckSubscription
{

    public function handle($request, Closure $next)
    {
        if($request->user()->subscribedtoPlan('monthly','basic')){
            return $next($request);
        }
        return redirect('payment');
    }
}

but while subscribed user get checked it redirects to subscription page.

Answers(1) :

finaly it worked out for me i changed the code too..

class CheckSubscription
{
    public function handle($request, Closure $next)
    {
        // $sub = Auth::user->subscription('main'->)

        if(!Auth::user()->subscription('main')){
            return redirect('payment');
        }
        return $next($request);

    }
}