jeudi 19 juillet 2018

Use Same Form Request But Pass Unique Code to The Form Request

I'm implementing a new way to writing Form Request rules and messages where I :

  • Have an activity (e.g. adding a user)
  • Attach a unique code to each activity (e.g. add_user)
  • Write the rules
  • Write the Messages on the rules

All this is done over a user interface, and the activities, rules and messages are stored in the DB and fetched as needed:

  • Create Form Request
  • Fetch rules and messages by passing the activity's unique code enter image description here

This therefore means that all my form requests shall be exactly the same, with the only difference being the code used to fetch the rules and messages. This therefore makes it cumbersome to have to create and import the Form Request every time.

And it made me to wonder, is there a way probably I can use the same Form Request and probably automatically pass to it the code when injecting it in the controller.

Any ideas?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire