Support the ongoing development of Laravel.io →
Requests Validation
Last updated 2 years ago.
0
Solution

Sure. You can set a where() route parameter filter or better do it in a separate before filter.

Something like this :

Route::filter('valid-date', function($route, $request)
{
	$date = $route->parameters();

	$start_date = Carbon::createFromDate(2014, 1, 1);
	$input_date = Carbon::createFromDate( $date['year'], $date['month'], $date['day'] );

	// gte() -> 'greater than or equal to', method of Carbon  package.

	if( ! $input_date->gte( $start_date ) ) {
		echo "Take action. Something like App::abort(404) ";
	}
    
});
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

mehmet mehmet Joined 18 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.