PHP Enum "Inheritance " in Filament

First off, I know you can't extend an enum in PHP, I'm trying to figure a way to accomplush that functionality though for the Filament getLabel, etc methods.

Lets say I have a base "Laravel" package that has among other things, an enum.
It's a plain 'ol, string backed enum. Nothing fancy.

If I then have a Filament plugin (package) that wants to use that enum, PHP lacking enum inheritance strikes again.

Does anyone have any preferred 'tricks' for 'extending (but not really)' an enum in this Filament package so that it has the getLabel, getColor, etc methods?

For example, the base Laravel package would have no Filament dependencies.
It could have an enum like
enum BaseStatus: string {
  case Success = 'success';
}


and in the Filament plugin that uses it, I'd like to have some way to 'add' the getLabel, etc to it.

In a dream world:

enum Status: string extends BaseStatus {
  // Cases are carried over from the base
  public function getLabel() {
    // ...
  }
}


Been scratching my head at a clean way to solve this for a day or two. Just didn't know if anyone else had encountered this or knew of a good way to handle it. Thanks!
Was this page helpful?