© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
Shaung Bhone

Laravel Enum with Filament

How can I render enum in laravel blade? When I add laravel casting like this
protected $casts = [
    'type' => EmploymentType::class,
];
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>
<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
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()
tryFrom()
again. Just use it
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Filament Enum
FilamentFFilament / ❓┊help
3y ago
Laravel Pennant with Filament
FilamentFFilament / ❓┊help
3y ago
Filament Laravel with front React
FilamentFFilament / ❓┊help
15mo ago
AWS S3 with Filament Laravel
FilamentFFilament / ❓┊help
2y ago