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 use aliased class constants :
First, create your class that contain your constants : App/MyApp.php
for exemple
namespace App;
class MyApp {
const MYCONST = 'val';
}
Then add it to the aliased classes in the config/app.php
'aliases' => [
//...
'MyApp' => App\MyApp::class,
Finally use them wherever you like (controllers or even blades) :
MyApp::MYCONST