Defining gloabal variables through helper function files

Posted 6 months ago by Thavarshan

Instead of sharing data with all views through the AppServiceProvider is it advisable to register a helper file in composer.json and load global variable to all views through helper functions?

For instance: I need to load a list categories to all my views. But when I load it through my AppServiceProvider and I don't have a database yet I receive an error instead of the view loading up normally and display a message saying "No categories found".

This is to avoid getting an ugly error basically.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.