Using the enum label with a text column in my table.
I read the doc. That not work for me. Where am I do wrong?
CompanyResource.php
Company.php
24 Replies
did you add
HasLabel
to EmploymentTypeYes
Are you sure you added the 'implements HasLabel' to the enum declaration, as well as adding the HasLabel method?
if you could change the name from
type
not sureThis was supposed to work... What is the output on the table?
key!. not label.
is the 'full time' a key?
should work. Could you share the project on github?
I think you still need to pass
->enum(EmploymentType::class)
?Alright. Was just guessing. On mobile right now 😅
@Shaung Bhone Ok this is a longshot but can you rename (or make a copy of) the
enum
column to something other than type
(eg employment_type
) and try again?
Also, do other types have the same issue? eg if you change full time
to contract
, does it still not work?I don't think so, as you can see currency that is not showing label.
SelectColumn is working.
TextColumn is not work.
Only thing that looks odd to me is the underscores in the case names. Can you try it with pascal case instead?
I would like to try this repo because this doesn't make sense for me 😅
Yeah, I've dug pretty deep into the code, created a test case on the Demo app, and I can't see how it fails. If the $state of that column is an instance of the enum with the GetLabel interface, Filament will call getLabel() on it. And the $state is just fetched from the $record returned from the Eloquent query. So for whatever reason, that $state is not the EmploymentType enum class when it reaches Filament.
So I think the problem is elsewhere in Shaung's app, but I have no idea where.
Thank you all let me try again and I got still stuck I will DM you.
Just FYI, my PR to add an Enum example to the Demo app has been merged, so you can use it as a sanity check if you want. Just install / update the demo, and there's a working example of column badges with colors, and a Select.
https://github.com/filamentphp/demo/commit/f2a27fd03ba8a8d2c2b1287d6b3949a456e47be7
GitHub
Merge pull request #84 from cheesegrits/feature-enum · filamentphp/...
Convert Order 'status' to be Enum
Thank you
Solution
I don't have cast in my Model.
Your OP shows a cast for it?
Yes
Wrong model
Lol
My bad