2016-07-14 14 views
1

Wenn ich die Routenliste von Befehlsform doc überprüfen:php Handwerker Route: Liste Runtime Session speichert nicht auf Anfrage gesetzt

php artisan route:list //RuntimeException: Session store not set on request. 

Ich fand es sollte eine bessere Nutzung Helferfunktion session() statt $request->session() in Controller __contract Funktion sein.

class SomeController extends Controller 
{ 
    public function __construct(Request $request) 
    { 
     //use $request->session()->has($var) will occur the exception as this post said. 
     if (session()->has($var)) {   
     //do something; 
    } 
} 

}

+0

Formatierte in-line-Inhalt. – AlBlue

Antwort

1

Verwenden session() statt $request->session() in Controller, wie:

class SomeController extends Controller 
{ 
    public function __construct(Request $request) 
    { 
     //use $request->session()->has($var) will occur the exception as this post said. 
     if (session()->has($var)) {   
     //do something; 
     } 
    } 
}