PHP Developers Network
http://forums.devnetwork.net/

Understanding onDelete cascade in laravel migrations
http://forums.devnetwork.net/viewtopic.php?f=72&t=143356
Page 1 of 1

Author:  gautamz07 [ Sat Feb 11, 2017 2:49 pm ]
Post subject:  Understanding onDelete cascade in laravel migrations

I was going through this section in the laravel documentation:


I saw the below line of code:

Syntax: [ Download ] [ Hide ]
$table->foreign('user_id')
      ->references('id')->on('users')
      ->onDelete('cascade');
 


I am not quite understanding the onDelete part , can somebody please explain that to me ?

Thank you.
Gautam.

Author:  Celauran [ Sun Feb 12, 2017 9:24 am ]
Post subject:  Re: Understanding onDelete cascade in laravel migrations

You have a user model. Comments belong to a user. With cascading deletes, deleting a user would also delete all their comments.

Author:  gautamz07 [ Sun Feb 12, 2017 12:11 pm ]
Post subject:  Re: Understanding onDelete cascade in laravel migrations

Thanks got it ! :)

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/