我正在使用 Laravel 进行项目,并且在删除自定义 morphPivot 关系时遇到一些问题。
当我尝试删除关系时,出现以下错误:
Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (SQL: delete from `comment` where (`` = 01418755-c68e-4ea5-8043-cef348c47445))'
从它我认为 laravel 正在尝试通过 ids 删除,但 id 列没有名称,所以它找不到它。但是,我认为我明确定义了 id 列。这是我的类实现:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCommentTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('comment', function (Blueprint $table) {
$table->uuid('id');
$table->primary('id');
$table->text('content');
$table->boolean('spoiler')->default(false);
$table->boolean('hidden')->default(false);
$table->boolean('edited')->default(false);
$table->uuid('parent_id')->nullable();
$table->uuid('user_id');
$table->uuid('commentable_id');
$table->string('commentable_type');
$table->json('meta')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('comment');
}
}
慕森王