public function __construct($db) { parent::__construct($db); $this->accountService = new AccountService($db); }
public function bulk($ids, $action, $params = []) { if ($action == 'refund') { if (!$ids) { return 0; } $payments = $this->getRepo()->findByPublicIdsWithTrashed($ids); $successful = 0; foreach ($payments as $payment) { if (Auth::user()->can('edit', $payment)) { $amount = !empty($params['amount']) ? floatval($params['amount']) : null; $accountGateway = $payment->account_gateway; $paymentDriver = $accountGateway->paymentDriver(); if ($paymentDriver->refundPayment($payment, $amount)) { $successful++; } } } return $successful; } else { return parent::bulk($ids, $action); } }