Laravel Enum with Filament

How can I render enum in laravel blade? When I add laravel casting like this
protected $casts = [
    'type' => EmploymentType::class,
];


I can't render in blade file.
<span
  class="my-auto ml-3 rounded bg-pink-100 px-2.5 py-0.5 text-sm font-medium text-pink-800   dark:bg-pink-900 dark:text-pink-300">
    {{ __(EmploymentType::tryFrom($post->type)->name) }}
</span>


App\Enums\EmploymentType::tryFrom(): Argument #1 ($value) must be of type string|int, App\Enums\EmploymentType given
Solution
You already casted the value to an enum. No need for a tryFrom() again. Just use it
Was this page helpful?