I am rather new to laravel. I have a basic question, What is the best way to add constants in laravel. I know the .env method that we use to add the constants. Also I have mad
i think best way to define constant using a helper file. check my solution.
Define file path in composer.json
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"files": [
"app/helpers.php",
"app/Helper/function.php" // constant defined here
],
app/Helper/function.php
define("assetPath","UI/");
define("viewPath","UI/");
use this constant anywhere in project. i am using in blade file.
my approach is better than this
Config::get('constants.options');
Config::get('constants.options.option_attachment');
here another problem is this , you have to run cache:clear or cache command for this. but my approach not required this.