我正在使用 Laravel 進(jìn)行項目,并且在刪除自定義 morphPivot 關(guān)系時遇到一些問題。當(dāng)我嘗試刪除關(guān)系時,出現(xiàn)以下錯誤: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))'從它我認(rèn)為 laravel 正在嘗試通過 ids 刪除,但 id 列沒有名稱,所以它找不到它。但是,我認(rèn)為我明確定義了 id 列。這是我的類實現(xiàn):<?phpuse 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'); }}
無法刪除 morphpivot 自定義模型 laravel
慕田峪9158850
2023-08-26 15:55:57