two different enum class in one resource
It seems like I may have identified a bug, but I'm not certain. I have a resource (RepairResource) where both in the table and in the infolist, I display a repairState and a paymentState, which are two different ENUMs.
When I need to use the ENUMs of paymentState, I encounter this error: "Pending" is not a valid backing value for the App\Enums\RepairStatus enum. This is because the enums are being searched in the wrong place.
Here's the code:
If there's an issue where the Pending value is being treated as a value for RepairStatus enum instead of PaymentStatus
10 Replies
do i need to replicate the paymentStatus ENUM inside the repairStatus ENUM?
but if i put the paymentStatus inside the repiarStatus, when i need to use the repairStatus (for example in a select) i see also the paymentStatus..
This is because the enums are being searched in the wrong place.What does that mean?
both this
...
Components\TextEntry::make('repair_status')
->label('Repair status')
->badge(),
Components\TextEntry::make('payment_status')
->label('Payment status')
->badge(),
...
search the ENUMS in enums/repairStatus.php
but the enum definition for payment_status are in
enums/paymentStatus.php
when i want to update a repairStatus i see also the paymentStatus
Solution
Sounds like you specified the wrong cast
As there is no filament logic in your code that would map stuff to enums
And does the code default to that of RepairStatus? How can I specify which one to use?
Can you show your model casts?
doh...
i've just realized
protected $casts = [
'repair_status' => RepairStatus::class,
'payment_status' => RepairStatus::class,
'accessories' => 'array',
];
need to change here
thanks
Yeah, that's what I said.