【发布时间】:2022-01-25 21:22:47
【问题描述】:
public function up() {
Schema::create('orders', function (Blueprint $table) {
$table->increments('id');
$table->unsignedBigInteger('seller_id');
$table->foreign('seller_id')->references('id')->on('sellers')->onDelete('cascade');
$table->decimal('total',8,2);
$table->decimal('discount',8,2)->default(0);
$table->decimal('tax',8,2);
$table->boolean('paid')->default(0);
$table->timestamps();
});
}
卖家表
public function up() {
Schema::create('sellers', function (Blueprint $table) {
$table->increments('id');
$table->string('CompanyName');
$table->string('SellerName');
$table->string('email')->unique();
$table->string('password');
$table->bigInteger('contact');
$table->mediumText('officeAddress');
$table->string('city');
$table->string('state');
$table->rememberToken();
$table->timestamps();
});
}
我尝试了所有可能的方法来定义外键但无法成功请帮助我 enter image description here
【问题讨论】:
标签: laravel laravel-migrations