PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue May 30, 2017 6:02 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Feb 11, 2017 2:49 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 317
I was going through this section in the laravel documentation:
https://laravel.com/docs/5.4/migrations#foreign-key-constraints

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.


Top
 Profile  
 
PostPosted: Sun Feb 12, 2017 9:24 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6244
Location: Montreal, Canada
You have a user model. Comments belong to a user. With cascading deletes, deleting a user would also delete all their comments.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sun Feb 12, 2017 12:11 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 317
Thanks got it ! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group