我有两个表,students和parent,我创建了一个指向student表的外键,该表引用了父ID,但是当我插入数据时,数据库的外ID列为空
//Mock function
var mockPromise = new Promise((resolve, reject) => {
resolve(<mock response similar to actual promise response>);
});
functionName = jest.fn().mockReturnValueOnce(mockPromise)
//Mock action
const actions = [];
const dispatchAction = jest.fn((dispatchCall) => {
actions.push(dispatchCall);
});
functionName()(dispatchAction);
expect(dispatchAction).toBeCalledTimes(1)
Schema::create('students', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('pregistration_id')->unsigned();
$table->integer('admission_no')->unique();
$table->string('fname');
$table->string('mname');
$table->string('lname');
$table->date('dob');
$table->string('primary_school');
$table->string('form_enrolled');
$table->string('transfered_from');
$table->string('transfered_to');
$table->foreign('pregistration_id')->references('id')
->on('pregistrations');
$table->timestamps();
我的控制器
Schema::create('pregistrations', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->string('fname');
$table->string('mname');
$table->string('lname');
$table->string('residence');
$table->integer('phone');
$table->string('occupation');
$table->timestamps();
组件
return Student::create([
'pregistration_id'=>$request['pregistration_id'],
'admission_no'=>$request['admission_no'],
'fname'=>$request['fname'],
'mname'=>$request['mname'],
'lname'=>$request['lname'],
'dob'=>$request['dob'],
'primary_school'=>$request['primary_school'],
'form_enrolled'=>$request['form_enrolled'],
'transfered_from'=>$request['transfered_from'],
'transfered_to'=>$request['transfered_to'],
请任何可以帮助我的人
下面是我的组件代码
<tr v-for="student in students" :key="student.id">
<div v-for="pregistration in pregistrations"
:key="pregistration.id"></div>
<td>{{student.id}}</td>
<td>{{student.admission_no}}</td>
<td>{{student.fname|upText}}</td>
<td>{{student.mname|upText}}</td>
<td>{{student.lname|upText}}</td>
<td>{{student.dob}}</td>
<td>{{student.primary_school|upText}}</td>
<td>{{student.form_enrolled|upText}}</td>
<td>{{student.transfered_from|upText}}</td>
<td>{{student.transfered_to|upText}}</td>