mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-01 19:47:11 +00:00
Removed my own validation source in favour of Ardent.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
namespace Firefly\Database;
|
||||
|
||||
|
||||
abstract class SingleTableInheritanceEntity extends \Elegant
|
||||
abstract class SingleTableInheritanceEntity extends \LaravelBook\Ardent\Ardent
|
||||
{
|
||||
/**
|
||||
* The field that stores the subclass
|
||||
@@ -13,6 +15,7 @@ abstract class SingleTableInheritanceEntity extends \Elegant
|
||||
protected $subclassField = null;
|
||||
/**
|
||||
* must be overridden and set to true in subclasses
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isSubclass = false;
|
||||
@@ -67,12 +70,16 @@ abstract class SingleTableInheritanceEntity extends \Elegant
|
||||
}
|
||||
|
||||
// ensure that the subclass field is assigned on save
|
||||
|
||||
public function save(array $options = array())
|
||||
{
|
||||
public function save(
|
||||
array $rules = array(),
|
||||
array $customMessages = array(),
|
||||
array $options = array(),
|
||||
\Closure $beforeSave = null,
|
||||
\Closure $afterSave = null
|
||||
) {
|
||||
if ($this->subclassField) {
|
||||
$this->attributes[$this->subclassField] = get_class($this);
|
||||
}
|
||||
return parent::save($options);
|
||||
return parent::save($rules, $customMessages, $options, $beforeSave, $afterSave);
|
||||
}
|
||||
}
|
||||
@@ -91,9 +91,9 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
$journal->completed = false;
|
||||
$journal->description = $description;
|
||||
$journal->date = $date;
|
||||
if (!$journal->isValid()) {
|
||||
if (!$journal->save()) {
|
||||
\Log::error('Cannot create valid journal.');
|
||||
\Log::error('Errors: ' . print_r($journal->validator->messages()->all(), true));
|
||||
\Log::error('Errors: ' . print_r($journal->errors()->all(), true));
|
||||
throw new \Firefly\Exception\FireflyException('Cannot create valid journal.');
|
||||
}
|
||||
$journal->save();
|
||||
@@ -104,9 +104,9 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
$fromTransaction->transactionJournal()->associate($journal);
|
||||
$fromTransaction->description = null;
|
||||
$fromTransaction->amount = $amountFrom;
|
||||
if (!$fromTransaction->isValid()) {
|
||||
if (!$fromTransaction->save()) {
|
||||
\Log::error('Cannot create valid transaction (from) for journal #' . $journal->id);
|
||||
\Log::error('Errors: ' . print_r($fromTransaction->validator->messages()->all(), true));
|
||||
\Log::error('Errors: ' . print_r($fromTransaction->errors()->all(), true));
|
||||
throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (from).');
|
||||
}
|
||||
$fromTransaction->save();
|
||||
@@ -116,12 +116,10 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
$toTransaction->transactionJournal()->associate($journal);
|
||||
$toTransaction->description = null;
|
||||
$toTransaction->amount = $amountTo;
|
||||
if (!$toTransaction->isValid()) {
|
||||
if (!$toTransaction->isValid()) {
|
||||
\Log::error('Cannot create valid transaction (to) for journal #' . $journal->id);
|
||||
\Log::error('Errors: ' . print_r($toTransaction->validator->messages()->all(), true));
|
||||
throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (to).');
|
||||
}
|
||||
if (!$toTransaction->save()) {
|
||||
\Log::error('Cannot create valid transaction (to) for journal #' . $journal->id);
|
||||
\Log::error('Errors: ' . print_r($toTransaction->errors()->all(), true));
|
||||
throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (to).');
|
||||
}
|
||||
$toTransaction->save();
|
||||
|
||||
@@ -222,7 +220,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
$name = $t->account->name;
|
||||
$amount = floatval($t->amount) < 0 ? floatval($t->amount) * -1 : floatval($t->amount);
|
||||
|
||||
$result[$name] = isset($result[$name]) ? $result[$name]+$amount : $amount;
|
||||
$result[$name] = isset($result[$name]) ? $result[$name] + $amount : $amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ class EloquentUserRepository implements UserRepositoryInterface
|
||||
$user->reset = \Str::random(32);
|
||||
$user->password = \Hash::make(\Str::random(12));
|
||||
|
||||
if (!$user->isValid()) {
|
||||
if (!$user->save()) {
|
||||
\Log::error('Invalid user');
|
||||
\Session::flash('error', 'Input invalid, please try again: ' . $user->validator->messages()->first());
|
||||
\Session::flash('error', 'Input invalid, please try again: ' . $user->errors()->first());
|
||||
return false;
|
||||
}
|
||||
$user->save();
|
||||
|
||||
Reference in New Issue
Block a user