Build a Monthly Subscription App with Laravel Cashier: Lesson 29 of 36

Blade Conditionals

Up Next

Account Page Setup

Autoplaying in 7 seconds!

Cancel

Since we have the Billable trait on our User model, we have access to some methods that will show us if a user is subscribed or not. Here are some of the important methods:

Table of Contents

    // is a user subscribed?
    Auth::user()->subscribed('main');   // checks a certain subscription (main). returns true/false
    
    // did the user cancel? but still has an active subscription?
    Auth::user()->subscription('main')->onGracePeriod();
    
    // is a user on a certain plan? (bronze/silver/gold)
    Auth::user()->onPlan('bronze');     // returns true/false
    
    // check if a user had a subscription and cancelled (no longer in grace period)
    Auth::user()->subscription('main')->cancelled();

    Chris Sevilleja

    173 posts

    Founder of Scotch.io. Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.