cardProgram->cardProgramConditions; if ($conditions){ foreach ($conditions as $condition){ if ($condition->type === "cashback"){ $transactionForm = new CreateCardTransactionForm(); $transactionForm->load([ 'from' => 1001, 'to' => $card->id, 'amount' => $this->calcPercent($amount, $condition->value), 'type' => 1, 'status' => 1, ]); $transactionService = new CardTransactionService(); return $transactionService->create($transactionForm); } } } return false; } private function calcPercent($price, $percent): int { return round($price * ($percent / 100)); } }