Laravel 2 instances of BadMethodCallException: 'int does not exist' and 'method does not exist'

Chakeeel

I am currently doing migrations in Laravel via the Terminal, and have these two errors when attempting to use php artisan migrate; I will print errors below:

 BadMethodCallException  : Method Illuminate\Database\Schema\Blueprint::int does not exist.

  at /Users/shaquilenoor/Desktop/chatapi/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php:100
     96|      */
     97|     public function __call($method, $parameters)
     98|     {
     99|         if (! static::hasMacro($method)) {
  > 100|             throw new BadMethodCallException(sprintf(
    101|                 'Method %s::%s does not exist.', static::class, $method
    102|             ));
    103|         }
    104| 

  Exception trace:

  1   Illuminate\Database\Schema\Blueprint::__call("int")
      /Users/shaquilenoor/Desktop/chatapi/database/migrations/2019_01_29_045824_create_contacts_table.php:15

  2   CreateContactsTable::{closure}(Object(Illuminate\Database\Schema\Blueprint))
      /Users/shaquilenoor/Desktop/chatapi/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:164

It seems both errors stem from my CreateContactsTable, so I will print the code from that file below:

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateContactsTable extends Migration
{
    public function up()
    {
        Schema::create('contacts', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user1_id');
            $table->unsignedInteger('user2_id');
            $table->int('room_id')->unique();
            $table->timestamps();
            $table->foreign('room_id')->references('id')->on('rooms');
            $table->foreign('user1_id')->references('id')->on('users');
            $table->foreign('user2_id')->references('id')->on('users');
        });
    }

    public function down()
    {
        Schema::dropIfExists('contacts');
    }
}
Marcin Nabiałek

Error is in line:

$table->int('room_id')->unique();

There is no int method. You should use integer instead:

$table->integer('room_id')->unique();

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Laravel - method whereDate does not exist

分類Dev

Method links does not exist in Laravel

分類Dev

laravel pagination Method links does not exist

分類Dev

Method Paginate Does not exist in laravel 5.5

分類Dev

Method [validateA] does not exist in Laravel 5.0

分類Dev

Why does "Int" exist, but not "Float"?

分類Dev

RX Objservable - .of() method does not exist from angular 2 beta

分類Dev

With Cookie does not exist on response factory Laravel

分類Dev

Laravel 8. Seeder class does not exist

分類Dev

Angular2 - 'then' does not exist on type 'void'

分類Dev

Bundle Does Not Exist: Symfony2

分類Dev

Why does volatile exist?

分類Dev

Why does volatile exist?

分類Dev

Animation getTexture() does not exist?

分類Dev

Class Controller does not exist

分類Dev

"X" does not exist in this context

分類Dev

Does Zend Flashdata exist?

分類Dev

The "X" argument does not exist

分類Dev

Create a generic PreparedStatement method to check if value does exist in a Table

分類Dev

Route::controllers - Method [index] does not exist on [App\Http\Controllers

分類Dev

Method Illuminate\Database\Eloquent\Collection::paginate does not exist

分類Dev

ReflectionException Class does not exist happens on git branch switch Laravel

分類Dev

How to fix "Class signed does not exist" error in Laravel 5.7?

分類Dev

Laravel 5.7 Class App\Http\Controllers\Auth\VerificationController does not exist

分類Dev

'Property does not exist on type 'never'

分類Dev

Does attribute node exist in HTML?

分類Dev

Does copy elision exist in C?

分類Dev

Does splice exist for TypedArrays or is there an equivalent?

分類Dev

TypeScript '...' does not exist on type 'typeof ...'

Related 関連記事

ホットタグ

アーカイブ