Skip to content

Commit 458127b

Browse files
authored
Merge pull request #6 from A909M/fix/state-fusion-info-changes
fix(trait): replace static $name with getMorphClass() method
2 parents a014664 + e0856db commit 458127b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Concerns/StateFusionInfo.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait StateFusionInfo
1515
public static function getStatesLabel($model): array
1616
{
1717
return self::getStateMapping()->mapWithKeys(function ($stateClass) use ($model) {
18-
return [$stateClass::$name => (new $stateClass($model))->getLabel() ?? $stateClass::$name];
18+
return [$stateClass::getMorphClass() => (new $stateClass($model))->getLabel() ?? $stateClass::getMorphClass()];
1919
})->toArray();
2020
}
2121

@@ -30,10 +30,10 @@ public static function getStatesColor($model): array
3030
$instance = new $stateClass($model);
3131
// Check if the class implements HasColor interface before calling getColor
3232
if (method_exists($instance, 'getColor')) {
33-
return [$stateClass::$name => $instance->getColor()];
33+
return [$stateClass::getMorphClass() => $instance->getColor()];
3434
}
3535

36-
return [$stateClass::$name => null];
36+
return [$stateClass::getMorphClass() => null];
3737
})->toArray();
3838
}
3939

@@ -48,10 +48,10 @@ public static function getStatesDescription($model): array
4848
$instance = new $stateClass($model);
4949
// Check if the class implements HasDescription interface before calling getDescription
5050
if (method_exists($instance, 'getDescription')) {
51-
return [$stateClass::$name => $instance->getDescription()];
51+
return [$stateClass::getMorphClass() => $instance->getDescription()];
5252
}
5353

54-
return [$stateClass::$name => null];
54+
return [$stateClass::getMorphClass() => null];
5555
})->toArray();
5656
}
5757

@@ -66,10 +66,10 @@ public static function getStatesIcon($model): array
6666
$instance = new $stateClass($model);
6767
// Check if the class implements HasIcon interface before calling getIcon
6868
if (method_exists($instance, 'getIcon')) {
69-
return [$stateClass::$name => $instance->getIcon()];
69+
return [$stateClass::getMorphClass() => $instance->getIcon()];
7070
}
7171

72-
return [$stateClass::$name => null];
72+
return [$stateClass::getMorphClass() => null];
7373
})->toArray();
7474
}
7575
}

0 commit comments

Comments
 (0)