I have a constant class like so
Class MyConstants
{
const TEST = "asd";
const TEST123 = "foo";
const TEST333 = "fooBar";
const TEST321 = "bar";
}
In my controller I get all constants and select 3 at random, the problem is I only get the key from the constant but I need the value
$allConstants = $this->getAllConstants();
$foo = array_rand($allConstants, 3);
dd($foo)
array:3 [
0 => "TEST321"
1 => "TES"
2 => "TEST123"
]
How can i get instead the value of the constant which for example would be foobar ?
I also then need to save them to the database. Should i Loop over them ?
$fooBarEntity->setData($foo);
Thank you for your help.