public function _deleteConnections(Event $event) { /** @var AppConnections[] $appConnections */ $appConnections = AppConnections::find()->where(['app_id' => $this->id])->all(); $orderedConnection = []; foreach ($appConnections as $connections) { $orderedConnection[$connections->type][] = $connections; } foreach ($orderedConnection as $type => $connections) { $deleteList = []; foreach ($connections as $dataConnection) { $deleteList[] = $dataConnection->reference_id; } $type::deleteAll([$deleteList]); } }