lundi 1 août 2016

Laravel 5.2 Cashier Middlesware returning NotFoundHttpException

Im wondering if someone could help me out.

Im running Laravel 5.2, i have followed the instructions in the docos about installing Cashier.

There is an example of middleware in the docs regarding checking subscription status, but when i implement it, i get the following error

NotFoundHttpException in RouteCollection.php line 161:

My Middleware is as follows

<?php
    namespace App\Http\Middleware;

    use Closure;

    class RedirectIfNotBilled
    {
        public function handle($request, Closure $next)
        {

            if ($request->user() && ! $request->user()->subscribed()) {

                return redirect()->route('user.billing');
            }

            return $next($request);

        }
    }

I added the middleware in my Kernel.php in the $routeMiddleware as follows

'billed' => \App\Http\Middleware\RedirectIfNotBilled::class,

The following is my routes

Route::group(['middleware' => 'auth'], function() {

    Route::get('dashboard', [
        'uses' => 'BackendController@getDashboard',
        'as' => 'backend.dashboard',
        'middleware' => 'billed'
    ]);

});

Route::get('billing', [
    'uses' => 'UserController@getBillingInfo',
    'as' => 'user.billing'
]);

Any help on this would be greatly appreciated.

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire