Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lewisbhs's avatar

Change Spark Registration

Hi,

How can I change Laravel Sparks default registration fields? I want to change 'name' to 'user_name', additionally how can I add more fields to it such as first_name, last_name, company_name, etc?

I've tried many things to change 'name' to 'user_name' but so far have had no luck.

Thanks in advance.

0 likes
4 replies
svyandun's avatar

Hi,

I had to do something similar. I recommend reading the source, see what parts change and try to swap them. If you want to change behaviour entirely, just redefine the appropriate route. If you want to change specific things, take advantage of the container since most dependencies are coded to an interface. Extend the class with the behaviour you want to change, override and register it in your providers.

Good luck!

lewisbhs's avatar

@EventFellows Will I just be able to remove the 'name' part from the template files and it will no longer be required? Thank you.

EventFellows's avatar

No, that does not work. name is hardcoded into many aspects of the user including a corresponding database collumn and throughout the codebase.

You can overwrite the validation rules using the Spark::swap method like this (see documentation):

        Spark::swap('CreateUser@rules', function () {
            return [
            'name' => 'required|unique:users,name|min:5|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
            'vat_id' => 'max:50|vat_id',
            'terms' => 'required|accepted',
            ];
        });

But I would guess that removing/ or not populating the name field causes trouble in other places where the variable is then undefined (but you can give it a try).

Why don't you just change it in the frontend and just leave the variable name as it is?

Please or to participate in this conversation.