Reputation: 5442
Consider the following URIs:
countries/{country}/persons/{person}/someAction
cities/{city}/persons/{person}/anotherAction
I do already have a rule check_country_contains_person
working fine, but I should extend it to check_group_contains_person
to be used in both method's validation classes.
Inside Validation Rule's passes
function, how can I check if request()->route('country')
and/or request()->route('city')
are available or not?
Please note that if I were sure which one exists, I could do the rest. That's just about checking availability of the route parameters.
Upvotes: 2
Views: 4156
Reputation: 473
To check existence of a route parameter in laravel just check this:
is_null($request->route('sample'))
Upvotes: 2