Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->foreignId('post_id')->constrained('posts')->cascadeOnDelete();
$table->bigInteger('parent_id')->unsigned()->nullable();
$table->text('comment');
$table->timestamps();
});
2023_12_23_113538_add_foreign_key_on_comments_table_for_parent_id.php
Schema::table('comments', function(Blueprint $table) {
$table->foreign('parent_id')
->references('id')
->on('comments')
->onDelete('cascade');
});
şimdi bu kodları
Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->foreignId('post_id')->constrained('posts')->cascadeOnDelete();
$table->foreignId('parent_id')->nullable()->constrained('comments')->cascadeOnDelete();
$table->text('comment');
$table->timestamps();
});
böyle yazabilirim dimi