I suppose I should just be able to instantiate a new object from the Company class and user the 'company name' to create a new company before the user has been created? Oh man.
What I need is a "tutor". Haha :)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I created a new application, and added authentication using the php artisan make:auth command. I then changed the user registration form only collecting 1 value, the name, to collect the first name and last name.
Now I am trying to figure out how to create a Company when a new user is registered. I created a migration, model, and controller for Company using the php artisan make:model Company -mc command.
I tested things using artisan tinker and was able to create a new company. The problem is that the user enters the company name in the form, but I am not storing the company name in the 'users' table, I have a company_id field in the users table.
So should I create the user with a placeholder company ID, then take the company name to create a new company, get the ID for that company, and update the user record with the correct company_id value?
That feels clumsy.
More than 1 user will/can have the same company_id value. I want to allow that first user to invite employees and have those users assigned the same company_id value, but that's down the road :)
Please or to participate in this conversation.