1

I have 2 models, usergroups and usergrouppermissions. my usergrouppermissions has a field called user_group_id which links back to the main usergroup. In a case where I want to delete the user group, I automatically want it to delete the entry in the database for usergrouppermissions (as the user group wont exist) anymore. I have tried delete, however, it just deletes the usergroup.

  // Here is my model: (usergroup):
  public $hasMany = array(
       'UserGroupPermission'
  );

  // Here is the usergrouppermissions model:
  public $belongsTo = array(
        "UserGroup"
    );
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
mauzilla
  • 3,574
  • 10
  • 50
  • 86

1 Answers1

1

Try:

$this->Model->delete($item_to_delete_id,true);

delete() docs.

L. Sanna
  • 6,482
  • 7
  • 33
  • 47