Strip newlines and tabs from description.

This commit is contained in:
James Cole 2018-09-23 06:53:15 +02:00
parent 82e7202ad2
commit 8fd64791d6
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -36,6 +36,11 @@ use Log;
*/
class TransactionJournalFactory
{
/** @var User The user */
private $user;
use JournalServiceTrait, TransactionTypeTrait;
/**
* Constructor.
*/
@ -46,10 +51,6 @@ class TransactionJournalFactory
}
}
use JournalServiceTrait, TransactionTypeTrait;
/** @var User The user */
private $user;
/**
* Store a new transaction journal.
*
@ -67,13 +68,15 @@ class TransactionJournalFactory
$type = $this->findTransactionType($data['type']);
$defaultCurrency = app('amount')->getDefaultCurrencyByUser($this->user);
Log::debug(sprintf('Going to store a %s', $type->type));
$description = app('steam')->cleanString($data['description']);
$description = str_replace(["\n", "\t", "\r"], "\x20", $description);
$journal = TransactionJournal::create(
[
'user_id' => $data['user'],
'transaction_type_id' => $type->id,
'bill_id' => null,
'transaction_currency_id' => $defaultCurrency->id,
'description' => $data['description'],
'description' => $description,
'date' => $data['date']->format('Y-m-d'),
'order' => 0,
'tag_count' => 0,