Im new to CakePHP and all this with associations. When I want to delete a category, I also want to remove the competencies associated with the category. These are my table models:
CategoriesTable.php
class CategoriesTable extends Table
{
public function initialize(array $config)
{
parent::initialize($config);
$this->belongsToMany('Competences');
}
}
CompetencesTable.php
class CompetencesTable extends Table
{
public function initialize(array $config)
{
parent::initialize($config);
$this->belongsToMany('Categories');
$this->belongsToMany('CategoriesCompetences');
}
}
CategoriesCompetencesTable.php
class CategoriesCompetencesTable extends Table
{
public function initialize(array $config)
{
parent::initialize($config);
$this->belongsTo('Categories');
$this->hasMany('Competences');
}
}
When I delete a category, it deletes the rows in the link table, but not in the competencies in the CompetenceTable. I know that I forgot something, but I canβt understand that.
source
share