Hello, i have a code like this
if ($validation->fails()) {
foreach ($validation->messages()->all() as $message) {
Flash::error($message);
}
return Redirect::back()->withInput();
}
and i am using this code almost every form validation. Instead of writing (or copy/paste) this code all the time i want to make a own class which can be called from everywhere of my project. I created my class folder under the app folder and added it to global.php and its working awesome.
but when i create a static function like this insede my Helper class
class Helper {
public static function FlashValidationMessage($validation) {
if ($validation->fails()) {
foreach ($validation->messages()->all() as $message) {
Flash::error($message);
}
return Redirect::back()->withInput();
}
}
}
and put this code inside the controller
return Helper::FlashValidationMessage($validation);
when validation fails everything works great, but when validation passes function returns nothing so i see only a white blank screen.
What are your suggestion to work this function properly? Maybe i need another clever approach.
Thanks for the replies.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community