public function beforeDelete() { if ($this->id) { $wallets = Wallet::getList(['where' => ['currency_id', $this->id]]); foreach ($wallets as $wallet) { $wallet->delete(); } } }