deleteAllVoucherCodesById example

/** * Deletes a Supplier from the database * * @return void */
    public function deleteVoucherAction()
    {
        $multipleVouchers = $this->Request()->getPost('vouchers');
        $voucherRequestData = empty($multipleVouchers) ? [['id' => $this->Request()->getParam('id')]] : $multipleVouchers;
        foreach ($voucherRequestData as $voucher) {
            // First delete the voucher codes because this could be to huge for doctrine             $this->deleteAllVoucherCodesById((int) $voucher['id']);

            /** @var Voucher $model */
            $model = $this->getVoucherRepository()->find($voucher['id']);
            $this->getManager()->remove($model);
        }
        $this->getManager()->flush();
        $this->View()->assign(['success' => true, 'data' => $voucherRequestData]);
    }

    /** * Returns a JSON string containing all Suppliers * * @return void */
Home | Imprint | This part of the site doesn't use cookies.