I want to use some enum classes in my laravel 5 app. They are modeled after this PHP man page example: http://php.net/manual/en/class.splenum.php
The file app\Enums.php looks like this:
<?php
namespace MyApp\Enums;
class ItemStates extends SplEnum
{
const __default = self::Active;
const Active = 1;
const Pending = 2;
}
class ItemVisibility extends SplEnum
{
const __default = self::Community;
const Community = 1;
const Personal = 2;
}
I want to use these from a controller. I put a use statement at the top of my controller:
use MyApp\Enums;
When I try to use the class like this:
if ($category['Family'] == CategoryFamily::General)
I get an error: Class 'MyApp\Http\Controllers\Quiz\CategoryFamily' not found
I have run compose dump-autoload in case that matters.
How can I use my Enum classes from inside controllers (multiple controllers)?