Fix to prevent redefinition of functions for laravel workbench packages.

Just nesting the function definition in a if statement that checks whether the function is declared to prevent redefinition of the function. I was running into problems of this function getting redefined when doing some larval package development. This appears to change the entire file, but the only change is the if statement syntax directly before and after the function definition. All other changes highlighted in the diff were caused by spacing changes made to make the code more readable for an if statement.