所以我有3个表:用户,客户和预订。保存登录用户的外键作为外键
各关系和外键:
用户有一个客户。客户属于用户。 Users.id = Customers.user_id
Customers hasMany Bookings。预订属于客户。 Customers.id = Bookings.customer_id
在添加表单中,当进行预订时,我想将登录用户的客户ID保存为预订的customer_id。
领域:
在用户表:
-id
-username
-password
-role_id (connected to roles table) -created
-modified
在Customers表:
-id
-user_id (the foreign key connected to Users table)
-name
-created
-modified
在登记表中:
-id
-customer_id (the foreign key connected to Customers table)
-payment_id (connected to payments table)
-created
-modified
isnt user == customer?你有什么尝试?你遵循惯例吗? –
出于安全目的,用户和客户是分开的 - 用户有用户名和密码,客户有姓名和电话号码。我试过了:$ customer = $ booking-> Customers-> findByuser_id('Auth.User') - > first(); – mistaq
什么是安全的? –