Modifying User Table
New to Filament...How can I modify the user table? For example, I changed the migration to use "first_name" and "last_name" instead of "name". I extended the MakeFIlamentUser command to add the needed fields and that works fine. However, I get
Filament\FilamentManager::getUserName(): Return value must be of type string, null returned
when the page loads. Googling makes me think literally no one has had this requirement before, which I find odd. I found only one question posted and the person said they solved it by changing it back to "name". Surely I'm missing something..4 Replies
Maybe just add a name attribute to the model and return a concatenated first + last.
Looking at the
FilamentManager
code, you can see that the getUserName() method is looking for a few things that you can directly implement in your own model:
So ... if your Use model implements the HasName interface and provides the getFilamentName() method, you can use that to customize the name it retrieves. Or, as you can see, it falls back to an attribute/property of 'name', so you could simply add a getter attribute for 'name' ... either one would probably be just concatenating the two values you used.As @awscodes says I had to implement
Thanks, I guess I overlooked this in the docs:
https://filamentphp.com/docs/3.x/panels/users#configuring-the-users-name-attribute