diff --git a/app/Rules/ValidTransactions.php b/app/Rules/ValidTransactions.php new file mode 100644 index 0000000000..9d7ff7403f --- /dev/null +++ b/app/Rules/ValidTransactions.php @@ -0,0 +1,61 @@ +user()->id; + foreach ($value as $transactionId) { + $count = Transaction::where('transactions.id', $transactionId) + ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') + ->where('accounts.user_id', $userId)->count(); + if ($count === 0) { + Log::debug(sprintf('Count for transaction #%d and user #%d is zero! Return FALSE', $transactionId, $userId)); + return false; + } + } + Log::debug('Return true!'); + return true; + } +}