Binary Ulids
Hi
I'm trying to build an admin panel for a project. It already has a DB structure with ulid as primary keys. The DB schema has a
binary(16)
column type. I recreated it this way:
So that it works for the tests (i.e. I have the correct DB structure when running test suite)
I also use the HasUlids
trait and a custom cast for the primary key (as Laravel expects a char(26)
column type):
It seems to work when I dd
a model but I can't login to Filament, and tests fail too...
This is one of the errors I can have. The code is available at https://github.com/AlexandreGerault/mei-laravel/tree/refactor/ulid-primary-keys
I wonder what I can do to debug this 😅1 Reply
Disabling the cast allows me to log in successfully but I get this error. So the login fails if I enable the cast on ulid.
Now that I'm logged in, I can enable the cast again, and it displays correctly the table, but every resource page (edit/detail) fails with a 404 :/
Seems Laravel Eloquent works fine with the ulid charset set as a
binary(16)
but it breaks the json encode function, which is required to work for Laravel Livewire/Laravel Filament. I'm ** 😭