When i make a validation inside the Controller like in the following Laravel example:
Validator::make($request->all(), [ 'credit_card_number' => 'required_if:payment_type,cc' ]);
I can easily access the $request because I’m inside the controller method. However, I’ve noticed that using custom Request classes is considered a best practice in Laravel. I have a question regarding this: Is it possible to access the request variable inside the Request class?
2
Answers
Yes it is possible , and it is simple to access request inside Request class.
Your Request class :
As stated above, it is possible.
I would recommend reading through the Laravel best practices HERE
They provided me with lots of helpful tips to stick by.