Input to be validated is a tree where a subcategory is valid, only if its' parent category has been selected too.
The input values are as follows:
$categories = [1,2,3];
//in database, each subcategory has column "category_id"
$sub_categories = [4,5,6]
Validation
$this->validate([
"sub_categories.*" => [
"exists:sub_categories,id",
//Rule for checking that the category_id for this subcategory
//exists in the categories array.
]
])
Is there such a built in laravel rule or do I need to write the rule myself?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire