PS C:xampphtdocslearninglaragonlavue> php artisan migrate
Migrating: 2022_07_17_042348_create_transaction_details_table
BadMethodCallException
Method IlluminateDatabaseSchemaBlueprint::unsignedBidInteger does not exist.
at C:xampphtdocslearninglaragonlavuevendorlaravelframeworksrcIlluminateMacroableTraitsMacroable.php:113
109▕ */
110▕ public function __call($method, $parameters)
111▕ {
112▕ if (! static::hasMacro($method)) {
➜ 113▕ throw new BadMethodCallException(sprintf(
114▕ 'Method %s::%s does not exist.', static::class, $method
115▕ ));
116▕ }
117▕
1
终端错误
C: xampp 根 数据库laragon lavue 学习迁移 2022 _07_17_042348_create_transaction_details_table.php: 18照亮数据库模式蓝图:__call ()
2 C:xampphtdocslearninglaragonlavuevendorlaravelframeworksrcIlluminateDatabaseSchemaBuilder.php:256
IlluminateDatabaseMigrationsMigration@anonymousC:xampphtdocslearninglaragonlavuedatabasemigrations2022_07_17_042348_create_transaction_details_table.php:7$b5::{closure}()
this my PHP migration
<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transaction_details', function (Blueprint $table) {
$table->id();
$table->unsignedBidInteger('transaction_id');
$table->unsignedBigInteger('book_id');
$table->integer('qty');
$table->timestamps();
$table->foreign('transaction_id')->references('id')->on('transactions');
$table->foreign('book_id')->references('id')->on('books');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('transaction_details');
}
};
当我输入php artisan migration时,看到类似上面的错误
迁移文件中'transaction_id'声明有一个错别字。
您的迁移文件应该是这样的。检查有注释的行。
<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transaction_details', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('transaction_id'); // instead of $table->unsignedBidInteger('transaction_id')
$table->unsignedBigInteger('book_id');
$table->integer('qty');
$table->timestamps();
$table->foreign('transaction_id')->references('id')->on('transactions');
$table->foreign('book_id')->references('id')->on('books');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('transaction_details');
}
请仔细阅读