@@ -39,9 +39,9 @@ public function boot()
3939 $ this ->updateRouterBindings ();
4040 });
4141
42- $ this ->app [ ' router ' ]-> middleware ('api.auth ' , Auth::class);
43- $ this ->app [ ' router ' ]-> middleware ('api.throttle ' , RateLimit::class);
44- $ this ->app [ ' router ' ]-> middleware ('api.controllers ' , PrepareController::class);
42+ $ this ->addMiddlewareAlias ('api.auth ' , Auth::class);
43+ $ this ->addMiddlewareAlias ('api.throttle ' , RateLimit::class);
44+ $ this ->addMiddlewareAlias ('api.controllers ' , PrepareController::class);
4545 }
4646
4747 /**
@@ -118,6 +118,27 @@ protected function addRequestMiddlewareToBeginning(Kernel $kernel)
118118 $ kernel ->prependMiddleware (Request::class);
119119 }
120120
121+ /**
122+ * Register a short-hand name for a middleware. For Compatability
123+ * with Laravel < 5.4 check if aliasMiddleware exists since this
124+ * method has been renamed.
125+ *
126+ * @param $name
127+ * @param $class
128+ *
129+ * @return void
130+ */
131+ protected function addMiddlewareAlias ($ name , $ class )
132+ {
133+ $ router = $ this ->app ['router ' ];
134+
135+ if (method_exists ($ router , 'aliasMiddleware ' )) {
136+ return $ router ->aliasMiddleware ($ name , $ class );
137+ }
138+
139+ return $ router ->middleware ($ name , $ class );
140+ }
141+
121142 /**
122143 * Gather the application middleware besides this one so that we can send
123144 * our request through them, exactly how the developer wanted.
0 commit comments