Courses

How to Structure Laravel Projects

Moving Validation to Form Request Class

avatar

please can we get a link to the project file you are working with in this course so that following along can be moe efficient?

👍 1
avatar

To be honest, I didn't save any repositories for this course because they were all separate small experiments, relatively easy to re-create if needed.

avatar

How can I use form request classes when I have different rules depending on the state of an object?

A simple example might be a post in a blog. We have three properties: title, text and state. If the state is "draft" only the title is required. If state is "published" title and text should be required.

avatar

You can use rules like required_when or required_if from Laravel, and/or you can have custom validation rules built which would access all the data from the request. Adding on my to-do list to write an article about this specific example, in a few weeks.