As you can see in the error:
"BadMethodCallException compiled.php line in 6243: Method filter does not exist."
This is about this part: Route::filter
.
In Laravel 5 Middleware is the preferred way to handle it, instead of filters. They are not entirely gone:
Filters are not removed in Laravel 5. You can still bind and use your own custom filters using before
and after
.
source Upgrade Guide 4.2 > 5.0 (Scroll to
Route Filters) Here is explained how you can keep it working with Route
, but I would suggest migration anyway;
The following Laravel features have been deprecated and will be removed entirely with the release of Laravel 5.2 in December 2015:
- Route filters have been deprecated in preference of middleware.
source Upgrade Guide 5.1.0 (Scroll to Deprecations)
You can turn your authMobile
into middleware by following the steps as posted in the docs, but I would suggest you update your package from composer too and take a look at the jwt-auth Authentication docs, which has detailed information on how to make it work in Laravel 5 with the already included middleware.
If you are using 0.5.*
of jwt-auth
you just enable them in your <appname>/Http/Kernel.php
:
protected $routeMiddleware = [
...
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
];
Then you can include it in Controller level for example:
public function __construct()
{
// Here we can say we want to jwt auth all resource functions except index and show.
$this->middleware('jwt.auth', ['except' => ['index','show']]);
}
Or in your routes.
Route::group(['middleware' => ['before' => 'jwt.auth', 'after' => 'jwt.refresh']], function () {
..etc
Instead of applying the filters like you would in Laravel 4.2