php - MongoDBExceptionInvalidArgumentException
Get the solution ↓↓↓Getting this error while running migration in laravel. I Have rechecked my data type in the schema is a string.
As you can see in the schema the datatype is a string but still getting this error. Any solutions???
MongoDB\Exception\InvalidArgumentException
Expected "name" option to have type "string" but found "int"
at D:\CRUD\CRUD\vendor\mongodb\mongodb\src\Exception\InvalidArgumentException.php:60
56▕
57▕ $expectedType = $typeString;
58▕ }
59▕
➜ 60▕ return new static(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, get_debug_type($value)));
61▕ }
62▕ }
63▕
1 D:\CRUD\CRUD\vendor\mongodb\mongodb\src\Model\IndexInput.php:71
MongoDB\Exception\InvalidArgumentException::invalidType(""name" option", "string")
2 D:\CRUD\CRUD\vendor\mongodb\mongodb\src\Operation\CreateIndexes.php:118
MongoDB\Model\IndexInput::__construct([])
Migration where it stopped
public function up()
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->morphs('tokenable');
$table->index('name');
$table->unique('token', 64);
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
});
}
Answer
Solution:
Your problem is that you have changed the actual implementation of .
expects first parameter to be the column's
name
and second (optional) to be the unique index'sname
, but the original implementation uses , so the first one is the column
name
, but the second one is the column'ssize
, so that is not the same as a name...
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: installation failed, reverting ./composer.json and ./composer.lock to their original content.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.