Laravel 5:如何使用简单的出生日期中间件(过滤前)?

I want to print "Happy Birthday" if date is match else I want to show something. So I use middleware in my "/" route.

My route

Route::get('/', ['middleware' => 'dob', function(){
    return 'Hello World';
}]);

My kernel

protected $routeMiddleware = [
        'auth' => 'App\Http\Middleware\Authenticate',
        'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
        'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
        'dob' => 'App\Http\Middleware\DateOfBirth'
    ];

My Middleware/DateOfBirth.php

public function handle($request, Closure $next)
    {
        if($request->date('d/m') == '15/09' ){
            echo 'happy birthday';
        }
        return $next($request);
    }

I just change current date to 15 and access public app but why it's show Call to undefined method Illuminate\Http\Request::date() instead of "Happy Birthday" ?

Thanks in advance.

Just a little bit different with filter in Laravel 4

public function handle($request, Closure $next)
{
    if(date('d/m') == '15/09' ){
        echo 'happy birthday';
    }
    return $next($request);
}

As the exception says the problem is your call to the date() method on the request object. The default Request Class doesn't implement this method - did you extend the request class with this method? Or do you want to access any input data or data from A model or simply mean the php date() function? If you tell US what this method call should do then we can help better!?

As pointed out by others, there is not date() method on the request object. I think you need something more like:

public function handle($request, Closure $next)
{
    $date = $request->get('date');

    if((new \DateTime($date))->format('d/m') == '15/09' ){
        echo 'happy birthday';
    }
    return $next($request);
}