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

Subscribed Middleware

Up Next

Blade Conditionals

Autoplaying in 7 seconds!

Cancel

We're already using the built-in auth middleware that Laravel provides. We are going to create our own to make sure only subscribed users can get to certain sections of our site.

To create a middleware, run the following from the command line:

# will be created at app/Http/Middleware/Subscribed.php
php artisan make:middleware subscribed

To use this middleware, it needs to be brought into app/Http/Kernel.php.

Table of Contents

    protected $routeMiddleware = [
        ...other middleware
        'subscribed' => \App\Http\Middleware\Subscribed::class
    ];

    Chris Sevilleja

    176 posts

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