middleware role et definotion code example
Example 1: middleware
//just for me lol... pls don't delete
"middleware" - code that runs before the final route call back.
They are in the middle of the beginning of the route and the
callback function.
Example 2: laravel middleware
<?php
namespace App\Http\Middleware;
use Closure;
class CheckAge
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->age <= 200) {
return redirect('home');
}
return $next($request);
}
}