Let's say we have a same field in almost all tables with same rules for validation, for example something like slug, is it possible to create a rule to handle validation for all requests with the slug field?
Asked
Active
Viewed 29 times
1 Answers
0
You can create one main Request validation class and use it in all controllers and in requests you need more rules you can inherit from this main Request class to add more rules

Marcin Nabiałek
- 109,655
- 42
- 258
- 291
-
@Mic0 Sorry but if you want to user Laravel5 and generally PHP you should definitely look at http://php.net/manual/en/language.namespaces.php to learn them. – Marcin Nabiałek Apr 17 '15 at 17:03
-
I created a class *MainRequest* and i extend it from *Request* class, then i put a protected $validation variable within this class which contains global rules and within my custom request class which they extends MainRequest i add other rules to $this->validation variable and at the enf i return it at rules() method, i don't know if it's the right approach but it's working. thanks. – Ravexina Apr 17 '15 at 17:20