Wednesday, March 29, 2017

What does onDelete('cascade') mean?

Schema::table('posts', function (Blueprint $table) {
    $table->integer('user_id')->unsigned();

    $table->foreign('user_id')->references('id')->on('users')>onDelete('cascade');;
});

Does this mean that if I delete a post, the user will also be delete or does it mean if I delete a user, all their posts will be delete?



via code511788465541441

Advertisement