我有一个在会议上注册的背景。注册只有一个步骤,如果是免费注册。如果是付费注册,有两个步骤。
注册的第一步是用户填写注册表格,单击“商店注册”按钮后,信息存储在数据库中,区域表的列“状态”总是以"I“(不完全)的形式存储。
如果是免费注册,则没有其他步骤。
但如果这是付费注册,还有另一步。在本步骤2中,用户需要在会议开始日期之前支付注册。在登记付款后,登记表的“状态”栏保持值"C“(完整)。
怀疑:
如果是付费注册,则在step1必须向用户发出形式发票之后,在step2之后,即在支付之后,必须向用户发出发票/收据。
我的疑问是如何组织数据库为这种背景下的问题,形式和发票。在每个付费注册是必要的,首先发出形式后,用户点击“商店注册”按钮和所有注册信息存储在db,然后发出发票后付款。必须有两个模型/表“发票”和“形式”,每个模型/表与登记表有1到1的关系。还是只需要一个与登记表相关的表格?
现在,我创建了两个表Proforma和In发单,这些表与Registration的关系类似于1到1,但我不知道它是否正确。
表结构:
registration columns: id, status, conference_id, user_that_did_registration
proformas: id, proforma_number, registration_id
invoices: id, invoice_number, registration_id问题的相关模型:
登记模式:
class Registration extends Model
{
public function customer(){
return $this->belongsTo(User::class, 'user_that_did_registration', 'id');
}
public function participants(){
return $this->hasMany('App\Participant');
}
public function registration_types(){
return $this->belongsToMany('App\RegistrationType', 'registration_registration_types');
}
public function conference(){
return $this->belongsTo('App\conference');
}
public function proforma()
{
return $this->hasOne('App\Proforma');
}
public function invoice()
{
return $this->hasOne('App\Invoice');
}
}形式模式:
class Proforma extends Model
{
public function registration()
{
return $this->belongsTo('App\Registration');
}
}发票模式:
class Invoice extends Model
{
public function registration()
{
return $this->belongsTo('App\Registration');
}
}发布于 2018-06-23 14:19:33
根据你的描述,你的设计看起来非常接近。由于并非所有的登记都有形式或发票,因此将Proformas和发票放在单独的表格中是有意义的。我只做一次更改--如果Proformas和发票之间的关系真的是1比1,那么您可以将所有字段放在一个记录中:
Proformas
ID
Registration_ID
Proforma_Number
Invoice_Numberhttps://stackoverflow.com/questions/50991699
复制相似问题