Skip to content
Advertisement

Method IlluminateDatabaseSchemaBlueprint::unsignedBidInteger does not exist

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   

error in terminal

C:xampphtdocslearninglaragonlavuedatabasemigrations2022_07_17_042348_create_transaction_details_table.php:18 IlluminateDatabaseSchemaBlueprint::__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');
}

};

When i put php artisan migration sees an error like above

Advertisement

Answer

There is a typo in your migration file on ‘transaction_id’ declaration.

Your migration file should be like this. Check the line with the comment.

<?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');
}

Kindly read this.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement