Skip to content
Advertisement

Is there a better way to check for mandatory child in HasMany in Laravel?

I have a class AdBannerModel with an HasMany relationship to BannerLocalizedContentModel. When validating the model I call the method alterRulesForSaving where i want to check that the given AdBanner has at least the mandatory localizedContents. This is how I handle the check now, looking for suggestions.

JavaScript

Advertisement

Answer

you can check existence of relation with needed params

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement