Hi. I have model with relations many to many and I can't delete releted models. Here is code:
class GroupImages extends Model { public $id;
public function initialize()
{
$this->setSource('group_images');
$this->hasManyToMany('id', 'ImagesOfGroup', 'group_image_id', 'image_id', 'Images', 'id', ['alias' => 'ImagesOfGroup']);
}
public function setImages($arImages = [])
{
$this->ImagesOfGroup->delete();
}
}
class ImagesOfGroup extends Model { public $image_id; public $group_image_id;
public function initialize()
{
$this->setSource('images_of_group');
$this->belongsTo('image_id', 'Images', 'id');
$this->belongsTo('group_image_id', 'GroupImages', 'id');
}
}
I'm trying this $this->ImagesOfGroup->delete() but it is not working. Method delete returns true but when looking through logs there is no sql for delete records.