1

Trying to upgrade to Laravel and following this Laravel 5 upgrade

But when it comes to Filter routes for Sentry. I get this error:

FatalErrorException in RouteServiceProvider.php line 38: Class 'App\Providers\Session' not found

Related to this copied and pasted from previous L4 filter:

 namespace App\Providers;
 use Cartalyst\Sentry\Facades\Laravel\Sentry;
 use Illuminate\Routing\Router;
 use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
 use Illuminate\Support\Facades\Route;

 class RouteServiceProvider extends ServiceProvider {
   protected $namespace = NULL;   //using composer

   public function boot(Router $router)
   {
     parent::boot($router);

     Route::filter('Sentry', function(){
       if (!Sentry::check()) {
          Session::put('loginRedirect', Request::url());
          return Redirect::guest('login');
        } 
     });
   }
 }

The 'Session' is the issue. Any help appreciated, thanks.

Gustavo Straube
  • 3,744
  • 6
  • 39
  • 62
martyn
  • 230
  • 5
  • 22

2 Answers2

0

You have to import Session.

use Session;

Or prepend it with a backslash

\Session::put('loginRedirect', Request::url());

The same goes for Request and Redirect

lukasgeiter
  • 147,337
  • 26
  • 332
  • 270
0

Session facade exists under global namespace. Since your file is under App\Providers namespace, you have to use \Session::put('loginRedirect', Request::url()); instead of Session::put('loginRedirect', Request::url());.