Fixes #2 add enum transalation for difficulty_enum

This commit is contained in:
Jérémy Munsch 2023-05-27 16:38:01 +02:00
parent 802d7eda8e
commit c190de01d6
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
3 changed files with 22 additions and 1 deletions

View file

@ -2,6 +2,7 @@
namespace App\Traits\Enums;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Str;
/**
@ -27,7 +28,9 @@ trait BaseEnum
*/
public function label(): string
{
return self::toLabels()[$this->name];
$class = Str::snake(\class_basename(\get_class($this)));
return Lang::has("enums.{$class}.{$this->name}") ?
Lang::get("enums.{$class}.{$this->name}") : self::toLabels()[$this->name];
}
// * STATIC FETCH METHODS

View file

@ -0,0 +1,9 @@
<?php
return [
'difficulty_enum' => [
'easy' => 'leicht',
'medium' => 'mittlere',
'hard' => 'hart',
]
];

View file

@ -0,0 +1,9 @@
<?php
return [
'difficulty_enum' => [
'easy' => 'easy',
'medium' => 'medium',
'hard' => 'hard',
]
];