Forms cakephp4 create UUID in signup form

Hello,
I need to create UUID in a sign up form when signing up to a website, as I have two types of users Partners & Member both have a lot of different information stored so I can’t use the same table for both, my solution was to have the following:

Create a 3 forms - tables

  1. user table - id, uuid, username,password, role (member, partner) etc…
  2. members table - id uuid name, email, rest of fields
  3. partner table - id uuid partner name, contact name, email, rest of fields

on initial create user (user login) it generates a uuid so this can be stored in to the 2 relevant tables

how would I do this in either the model view or controller when a user signs up?

I’m at a loss

Regards

Mal

Hi,
my way to do this will be only one table :
Users
UUID, username, password, email, role, partner_name, contact_name …

and fields partner_name & contact_name null by default

then into your code, when you create a new user, you can store relevants informations.
if the User is a member, ignore contact & partner names, else use it

and if you want to use uuid, I recommand to use it as primary key

1 Like

Thanks I have done this, I think I was trying to over complex things tbh

The standard way to do this, IMO, is to skip the UUID field, and have a user_id column in both the members and partners tables. Assuming that the id field in users is an autoincrement column, that’ll be unique already.

1 Like