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.