Closed ahmedsayedabdelsalam closed 3 years ago
Hey, could you please post a full stack-trace? This should only happen if the first enum instance is resolved before the translator service is registered.
In general I recommend to don't use the labels()
method with translations - because labels have to be unique.
https://github.com/spatie/enum/blob/0868053bbe79464ca164ab75c6a59d1f7da05709/src/Enum.php#L296-L298
Instead you could add another method to the enum or just use the enum in your views for example __('app.'.$enum)
.
Fatal error: Uncaught ReflectionException: Class translator does not exist in /Users/ahmed/Sites/php/surepay/vendor/laravel/framework/src/Illuminate/Container/Container.php:836 Stack trace:
I'm unable to reproduce the error.
Tried in a fresh Laravel app - everything with the latest versions.
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.40",
"laravel/tinker": "^2.5",
"spatie/laravel-enum": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
I tired different enum and it's working, I think this issue in the class only thanks for your support, I'll close the issue.
when i use translator function inside
labels
method an exception is thrown with a message that theTranslator
class does not exist, any Ideas?