catalin8
5 days ago

Return additional values to the controller in the Form Request. Is this good practice ?

Posted 5 days ago by catalin8

I have a Category model and need to store new categories by receiving the category hierarchy from input as a string.

And I want to only add the categories that already have a parent, but at the same time return the parent_id to the controller in the validation (in case it exists), so only one database request is performed, instead of 2 (one in validation and another one to get the parent_id).

Is it good practice to build a Form Request that performs this validation and which passes the parent_id to the controller by adding it to the returned array ? Or is there a better way to achieve this ?

Please sign in or create an account to participate in this conversation.