7 months ago

How to delete subcategories when i delete parent category Without foriegn keys

Posted 7 months ago by Respect
// Category.php
function subcategories() {
  return $this->hasMany(Subcategory::class);

// Subategory.php
function category() {
  return $this->belongTo(Category::class);

i need when i delete category also delete it's subcategories
something link 
is there any way or should use foriegn keys

Please sign in or create an account to participate in this conversation.