Reputation: 191
Hello im currently trying to build a laravel page.
i am building up data and colors for my js/jquery charts in the controller. but im also using the same colors for my general app layout in the css file.
now where would i want to set colors to be able to change a certain color for all charts in my controllers and the layout in my css file?
Let's say i have a certain color for "bad" #ff0000, i want to change it to a diffrent tone of red like #ce2500 and i don't want to change every occurence.
you get the idea i guess?
or am i thinking / doing something completely wrong here?
EDIT what i have done so far:
in the CSS file i defined my colors for my app to stay in a certain style. custom.css.php:
--color_bad: #ff0000;
--color_good: #00a6eb;
--color_text: #000000;
--color_bg1: #e6e6e6;
--color_bg2: #b3b3b3;
--color_border: #4d4d4d;
--color_caption: #ffffff;
I also did this in the config for the controllers:
// COLORS
'color_bad' => '#ff0000',
'color_good' => '#00a6eb',
'color_text' => '#000000',
'color_bg1' => '#e6e6e6',
'color_bg2' => '#b3b3b3',
'color_border' => '#4d4d4d',
'color_caption' => '#ffffff',
im using the css variables through the css files and config('colors.color_bad')
for the controllers
so i brought it down to 2 points in the app where colors are defined and i wanted to break it furhter down to only one place
Upvotes: 2
Views: 1195
Reputation:
For most constants used globally across the application, storing them in config files is sufficient. It is also pretty simple
Create a new file in the app/config directory. Let's call it constants.php
In there you have to return an array of config values.
return [
'langs' => [
'es' => 'www.domain.es',
'en' => 'www.domain.us'
// etc
]
];
And you can access them as follows
Config::get('constants.langs');
// or if you want a specific one Config::get('constants.langs.en'); And you can set them as well
Config::set('foo.bar', 'test');
Upvotes: 2