Just starting to get into laravel and running into major issues migrating my vanilla php
to use it.
I created a middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Session;
class QwickAuthCheck
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->session()->has('qwick')) {
//
return redirect('home');
}
return $next($request);
}
}
I'm checking to see if a session is set. home
is a route I have in routes.php
Route::get('/', 'WebController@home')->name('home');
I register it in kernel.php
like so;
protected $routeMiddleware = [
........
........
'qwickAuth' => \App\Http\Middleware\QwickAuthCheck::class,
];
Now I want to apply the middleware
to
Route::get('login', 'WebController@login');
How can I do this?
I have tried;
Route::get('login', ['middleware' => ['qwickAuth'], 'WebController@login');
Laravel has a lot of documentation on their site but for some reason all their code is not giving snippets of how people use this framework. In the middleware documentation all they gave was this;
Route::get('admin/profile', ['middleware' => 'auth', function () {
//
}]);
How do I know how to use it seeing that I don't have a function
in my route
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1MDIg26
via IFTTT
Aucun commentaire:
Enregistrer un commentaire