mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Replaced Ardent with another package.
This commit is contained in:
parent
f4ecf2d1aa
commit
bb3ba42ce2
@ -60,55 +60,19 @@ class AccountController extends BaseController
|
||||
{
|
||||
|
||||
$type = $account->accountType->type;
|
||||
$name = $account->name;
|
||||
|
||||
/** @var \FireflyIII\Database\Account $acct */
|
||||
$acct = App::make('FireflyIII\Database\Account');
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $jrnls */
|
||||
$jrnls = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
/*
|
||||
* Find the "initial balance account", should it exist:
|
||||
*/
|
||||
$initialBalance = $acct->findInitialBalanceAccount($account);
|
||||
|
||||
/*
|
||||
* Get all the transaction journals that are part of this/these account(s):
|
||||
*/
|
||||
$journals = [];
|
||||
if ($initialBalance) {
|
||||
$transactions = $initialBalance->transactions()->get();
|
||||
/** @var \Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$journals[] = $transaction->transaction_journal_id;
|
||||
}
|
||||
}
|
||||
/** @var \Transaction $transaction */
|
||||
foreach ($account->transactions() as $transaction) {
|
||||
$journals[] = $transaction->transaction_journal_id;
|
||||
}
|
||||
|
||||
$journals = array_unique($journals);
|
||||
|
||||
/*
|
||||
* Delete the journals. Should get rid of the transactions as well.
|
||||
*/
|
||||
foreach ($journals as $id) {
|
||||
$journal = $jrnls->find($id);
|
||||
$jrnls->destroy($journal);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete the initial balance as well.
|
||||
*/
|
||||
if ($initialBalance) {
|
||||
$acct->destroy($initialBalance);
|
||||
}
|
||||
$name = $account->name;
|
||||
// find the initial balance account (the only other account that should be deleted)
|
||||
// find all journals for both accounts (or just the one) and delete them.
|
||||
// the rest will take care of itself.
|
||||
// in the least amount of queries possible.
|
||||
|
||||
// and it can be done in ONE query! or maybe two.
|
||||
$acct->destroy($account);
|
||||
|
||||
|
||||
$return = 'asset';
|
||||
switch ($type) {
|
||||
case 'Expense account':
|
||||
@ -123,8 +87,6 @@ class AccountController extends BaseController
|
||||
Session::flash('success', 'The ' . $return . ' account "' . e($name) . '" was deleted.');
|
||||
|
||||
return Redirect::route('accounts.index', $return);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -548,10 +548,10 @@ class TransactionController extends BaseController
|
||||
return Redirect::route('transactions.index', $data['what']);
|
||||
}
|
||||
} else {
|
||||
Session::flash('error', 'Could not update transaction: ' . $journal->errors()->first());
|
||||
Session::flash('error', 'Could not update transaction: ' . $journal->getErrors()->first());
|
||||
|
||||
return Redirect::route('transactions.edit', $journal->id)->withInput()->withErrors(
|
||||
$journal->errors()
|
||||
$journal->getErrors()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
/**
|
||||
* Class Account
|
||||
@ -224,17 +223,58 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
|
||||
// delete journals:
|
||||
$journals = \TransactionJournal::whereIn(
|
||||
'id', function ($query) use ($model) {
|
||||
$query->select('transaction_journal_id')
|
||||
->from('transactions')->whereIn(
|
||||
'account_id', function ($query) use ($model) {
|
||||
$query
|
||||
->select('id')
|
||||
->from('accounts')
|
||||
->where(
|
||||
function ($q) use ($model) {
|
||||
$q->where('id', $model->id);
|
||||
$q->orWhere(
|
||||
function ($q) use ($model) {
|
||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||
// TODO magic number!
|
||||
$q->where('accounts.account_type_id', 3);
|
||||
$q->where('accounts.active', 0);
|
||||
}
|
||||
);
|
||||
}
|
||||
)->where('accounts.user_id', $this->getUser()->id);
|
||||
}
|
||||
)->get();
|
||||
}
|
||||
)->delete();
|
||||
|
||||
/*
|
||||
* Trigger deletion:
|
||||
*/
|
||||
\Event::fire('account.destroy', [$model]);
|
||||
$model->delete();
|
||||
|
||||
// delete accounts:
|
||||
\Account::where(
|
||||
function ($q) use ($model) {
|
||||
$q->where('id', $model->id);
|
||||
$q->orWhere(
|
||||
function ($q) use ($model) {
|
||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||
// TODO magic number!
|
||||
$q->where('accounts.account_type_id', 3);
|
||||
$q->where('accounts.active', 0);
|
||||
}
|
||||
);
|
||||
})->delete();
|
||||
|
||||
return true;
|
||||
|
||||
@ -243,7 +283,7 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -263,8 +303,8 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
|
||||
$data = array_except($data, ['_token', 'what']);
|
||||
$account = new \Account($data);
|
||||
if (!$account->validate()) {
|
||||
var_dump($account->errors()->all());
|
||||
if (!$account->isValid()) {
|
||||
var_dump($account->getErrors()->all());
|
||||
exit;
|
||||
}
|
||||
$account->save();
|
||||
@ -290,12 +330,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
$model->name = $data['name'];
|
||||
$model->active = isset($data['active']) ? intval($data['active']) : 0;
|
||||
@ -415,7 +455,7 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -2,13 +2,12 @@
|
||||
|
||||
namespace FireflyIII\Database;
|
||||
|
||||
use Firefly\Exception\FireflyException;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Database\Ifaces\AccountTypeInterface;
|
||||
use FireflyIII\Database\Ifaces\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
/**
|
||||
* Class AccountType
|
||||
@ -19,11 +18,11 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
@ -32,7 +31,7 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -41,12 +40,12 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
@ -71,7 +70,7 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
/**
|
||||
* Class Budget
|
||||
@ -28,11 +27,11 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
$model->delete();
|
||||
|
||||
@ -42,7 +41,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -51,8 +50,8 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
$budget = new \Budget($data);
|
||||
$budget->class = 'Budget';
|
||||
|
||||
if (!$budget->validate()) {
|
||||
var_dump($budget->errors()->all());
|
||||
if (!$budget->isValid()) {
|
||||
var_dump($budget->getErrors()->all());
|
||||
exit;
|
||||
}
|
||||
$budget->save();
|
||||
@ -61,16 +60,16 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
$model->name = $data['name'];
|
||||
if (!$model->validate()) {
|
||||
var_dump($model->errors()->all());
|
||||
if (!$model->isValid()) {
|
||||
var_dump($model->getErrors()->all());
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -124,7 +123,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
@ -28,11 +28,11 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
$model->delete();
|
||||
|
||||
@ -42,7 +42,7 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -50,8 +50,8 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
$category->name = $data['name'];
|
||||
$category->class = 'Category';
|
||||
$category->user()->associate($this->getUser());
|
||||
if (!$category->validate()) {
|
||||
var_dump($category->errors());
|
||||
if (!$category->isValid()) {
|
||||
var_dump($category->getErrors());
|
||||
exit();
|
||||
}
|
||||
$category->save();
|
||||
@ -60,16 +60,16 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
$model->name = $data['name'];
|
||||
if (!$model->validate()) {
|
||||
var_dump($model->errors()->all());
|
||||
if (!$model->isValid()) {
|
||||
var_dump($model->getErrors()->all());
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
$validator = \Validator::make($model, \Component::$rules);
|
||||
|
||||
if ($validator->invalid()) {
|
||||
$errors->merge($validator->errors());
|
||||
$errors->merge($validator->getErrors());
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace FireflyIII\Database\Ifaces;
|
||||
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* Interface CUD
|
||||
@ -13,26 +13,26 @@ interface CUD
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model);
|
||||
public function destroy(\Eloquent $model);
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data);
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data);
|
||||
public function update(\Eloquent $model, array $data);
|
||||
|
||||
/**
|
||||
* Validates an array. Returns an array containing MessageBags
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace FireflyIII\Database\Ifaces;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -18,7 +18,7 @@ interface CommonDatabaseCalls
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id);
|
||||
|
||||
|
@ -2,14 +2,14 @@
|
||||
namespace FireflyIII\Database;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Firefly\Exception\FireflyException;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Database\Ifaces\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Database\Ifaces\PiggybankInterface;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* Class Piggybank
|
||||
@ -29,11 +29,11 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
$model->delete();
|
||||
}
|
||||
@ -41,7 +41,7 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -58,8 +58,8 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
|
||||
|
||||
$piggybank = new \Piggybank($data);
|
||||
if (!$piggybank->validate()) {
|
||||
var_dump($piggybank->errors()->all());
|
||||
if (!$piggybank->isValid()) {
|
||||
var_dump($piggybank->getErrors()->all());
|
||||
exit;
|
||||
}
|
||||
$piggybank->save();
|
||||
@ -68,12 +68,12 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
/** @var \Piggybank $model */
|
||||
$model->name = $data['name'];
|
||||
@ -90,8 +90,8 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
$model->reminder = null;
|
||||
}
|
||||
|
||||
if (!$model->validate()) {
|
||||
var_dump($model->errors());
|
||||
if (!$model->isValid()) {
|
||||
var_dump($model->getErrors());
|
||||
exit();
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ use FireflyIII\Database\Ifaces\RecurringInterface;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
use stdObject;
|
||||
|
||||
/**
|
||||
@ -31,11 +31,11 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
$model->delete();
|
||||
|
||||
@ -45,7 +45,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -71,8 +71,8 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
$recurring->date = $date;
|
||||
$recurring->skip = intval($data['skip']);
|
||||
|
||||
if (!$recurring->validate()) {
|
||||
var_dump($recurring->errors());
|
||||
if (!$recurring->isValid()) {
|
||||
var_dump($recurring->getErrors());
|
||||
exit();
|
||||
}
|
||||
|
||||
@ -82,12 +82,12 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
var_dump($data);
|
||||
|
||||
@ -104,8 +104,8 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
$model->repeat_freq = $data['repeat_freq'];
|
||||
$model->skip = intval($data['skip']);
|
||||
|
||||
if (!$model->validate()) {
|
||||
var_dump($model->errors());
|
||||
if (!$model->isValid()) {
|
||||
var_dump($model->getErrors());
|
||||
exit();
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ use FireflyIII\Database\Ifaces\PiggybankInterface;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
{
|
||||
@ -272,11 +272,11 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
@ -285,7 +285,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -305,8 +305,8 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
|
||||
|
||||
$repeated = new \Piggybank($data);
|
||||
if (!$repeated->validate()) {
|
||||
var_dump($repeated->errors()->all());
|
||||
if (!$repeated->isValid()) {
|
||||
var_dump($repeated->getErrors()->all());
|
||||
exit;
|
||||
}
|
||||
$repeated->save();
|
||||
@ -315,12 +315,12 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
@ -425,7 +425,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace FireflyIII\Database;
|
||||
|
||||
use Firefly\Exception\FireflyException;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Database\Ifaces\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Database\Ifaces\TransactionInterface;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* Class Transaction
|
||||
@ -21,11 +21,11 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
use SwitchUser;
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
@ -34,7 +34,7 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -48,22 +48,22 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
if (isset($data['description'])) {
|
||||
$transaction->description = $data['description'];
|
||||
}
|
||||
if ($transaction->validate()) {
|
||||
if ($transaction->isValid()) {
|
||||
$transaction->save();
|
||||
} else {
|
||||
throw new FireflyException($transaction->errors()->first());
|
||||
throw new FireflyException($transaction->getErrors()->first());
|
||||
}
|
||||
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
@ -140,7 +140,7 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -4,14 +4,13 @@ namespace FireflyIII\Database;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Firefly\Exception\FireflyException;
|
||||
use FireflyIII\Database\Ifaces\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Database\Ifaces\TransactionJournalInterface;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
/**
|
||||
* Class TransactionJournal
|
||||
@ -31,11 +30,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
/*
|
||||
* Trigger deletion.
|
||||
@ -58,7 +57,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -88,8 +87,8 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
/*
|
||||
* This must be enough to store the journal:
|
||||
*/
|
||||
if (!$journal->validate()) {
|
||||
\Log::error($journal->errors()->all());
|
||||
if (!$journal->isValid()) {
|
||||
\Log::error($journal->getErrors()->all());
|
||||
throw new FireflyException('store() transaction journal failed, but it should not!');
|
||||
}
|
||||
$journal->save();
|
||||
@ -171,12 +170,12 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
/** @var \FireflyIII\Database\TransactionType $typeRepository */
|
||||
$typeRepository = \App::make('FireflyIII\Database\TransactionType');
|
||||
@ -202,8 +201,8 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
/*
|
||||
* This must be enough to store the journal:
|
||||
*/
|
||||
if (!$model->validate()) {
|
||||
\Log::error($model->errors()->all());
|
||||
if (!$model->isValid()) {
|
||||
\Log::error($model->getErrors()->all());
|
||||
throw new FireflyException('store() transaction journal failed, but it should not!');
|
||||
}
|
||||
$model->save();
|
||||
@ -269,7 +268,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
$transaction->account()->associate($data['from']);
|
||||
$transaction->amount = $amount * -1;
|
||||
}
|
||||
if (!$transaction->validate()) {
|
||||
if (!$transaction->isValid()) {
|
||||
throw new FireflyException('Could not validate transaction while saving.');
|
||||
}
|
||||
$transaction->save();
|
||||
@ -446,7 +445,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ use FireflyIII\Database\Ifaces\TransactionTypeInterface;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\Collection;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* Class TransactionType
|
||||
@ -20,11 +20,11 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
@ -33,7 +33,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -42,12 +42,12 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
@ -72,7 +72,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
* @return \Eloquent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ class User
|
||||
|
||||
if (!$user->save()) {
|
||||
\Log::error('Invalid user with data: ' . isset($data['email']) ? $data['email'] : '(no email!)');
|
||||
\Session::flash('error', 'Input invalid, please try again: ' . $user->errors()->first());
|
||||
\Session::flash('error', 'Input invalid, please try again: ' . $user->getErrors()->first());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
35
app/lib/FireflyIII/Event/Event.php
Normal file
35
app/lib/FireflyIII/Event/Event.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace FireflyIII\Event;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
|
||||
class Event
|
||||
{
|
||||
|
||||
public function deleteAccount(\Account $account)
|
||||
{
|
||||
// get piggy banks
|
||||
$piggies = $account->piggybanks()->get();
|
||||
|
||||
// get reminders for each
|
||||
/** @var \Piggybank $piggyBank */
|
||||
foreach ($piggies as $piggyBank) {
|
||||
$reminders = $piggyBank->reminders()->get();
|
||||
/** @var \Reminder $reminder */
|
||||
foreach ($reminders as $reminder) {
|
||||
$reminder->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
// triggers when others are updated.
|
||||
$events->listen('account.destroy', 'FireflyIII\Event\Event@deleteAccount');
|
||||
}
|
||||
}
|
@ -20,8 +20,8 @@ class Piggybank
|
||||
$event->piggybank()->associate($piggybank);
|
||||
$event->amount = floatval($amount);
|
||||
$event->date = new Carbon;
|
||||
if (!$event->validate()) {
|
||||
var_dump($event->errors());
|
||||
if (!$event->isValid()) {
|
||||
var_dump($event->getErrors());
|
||||
exit();
|
||||
}
|
||||
$event->save();
|
||||
@ -60,8 +60,8 @@ class Piggybank
|
||||
$event->piggybank()->associate($piggyBank);
|
||||
$event->amount = floatval($relevantTransaction->amount * -1);
|
||||
$event->date = new Carbon;
|
||||
if (!$event->validate()) {
|
||||
var_dump($event->errors());
|
||||
if (!$event->isValid()) {
|
||||
var_dump($event->getErrors());
|
||||
exit();
|
||||
}
|
||||
$event->save();
|
||||
@ -80,8 +80,8 @@ class Piggybank
|
||||
$event->piggybank()->associate($piggybank);
|
||||
$event->amount = floatval($amount);
|
||||
$event->date = new Carbon;
|
||||
if (!$event->validate()) {
|
||||
var_dump($event->errors());
|
||||
if (!$event->isValid()) {
|
||||
var_dump($event->getErrors());
|
||||
exit();
|
||||
}
|
||||
$event->save();
|
||||
@ -165,8 +165,8 @@ class Piggybank
|
||||
$event->transactionjournal()->associate($journal);
|
||||
$event->amount = floatval($relevantTransaction->amount);
|
||||
$event->date = new Carbon;
|
||||
if (!$event->validate()) {
|
||||
var_dump($event->errors());
|
||||
if (!$event->isValid()) {
|
||||
var_dump($event->getErrors());
|
||||
exit();
|
||||
}
|
||||
$event->save();
|
||||
@ -300,8 +300,8 @@ class Piggybank
|
||||
$event->transactionJournal()->associate($journal);
|
||||
$event->amount = $diff;
|
||||
$event->date = new Carbon;
|
||||
if (!$event->validate()) {
|
||||
var_dump($event->errors());
|
||||
if (!$event->isValid()) {
|
||||
var_dump($event->getErrors());
|
||||
exit();
|
||||
}
|
||||
$event->save();
|
||||
|
@ -6,7 +6,7 @@ namespace FireflyIII\Exception;
|
||||
/**
|
||||
* Class FireflyException
|
||||
*
|
||||
* @package Firefly\Exception
|
||||
* @package FireflyIII\Exception
|
||||
*/
|
||||
class FireflyException extends \Exception
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace FireflyIII\Exception;
|
||||
/**
|
||||
* Class ValidationException
|
||||
*
|
||||
* @package Firefly\Exception
|
||||
* @package FireflyIII\Exception
|
||||
*/
|
||||
class ValidationException extends \Exception
|
||||
{
|
||||
|
@ -3,7 +3,7 @@ namespace FireflyIII\Shared\Preferences;
|
||||
/**
|
||||
* Class PreferencesHelper
|
||||
*
|
||||
* @package Firefly\Helper\Preferences
|
||||
* @package FireflyIII\Shared\Preferences
|
||||
*/
|
||||
class Preferences implements PreferencesInterface
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace FireflyIII\Shared\Preferences;
|
||||
/**
|
||||
* Interface PreferencesHelperInterface
|
||||
*
|
||||
* @package Firefly\Helper\Preferences
|
||||
* @package FireflyIII\Shared\Preferences
|
||||
*/
|
||||
interface PreferencesInterface
|
||||
{
|
||||
|
@ -1,14 +1,12 @@
|
||||
<?php
|
||||
namespace FireflyIII\Shared;
|
||||
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
/**
|
||||
* Class SingleTableInheritanceEntity
|
||||
*
|
||||
* @package FireflyIII\Shared
|
||||
*/
|
||||
abstract class SingleTableInheritanceEntity extends Ardent
|
||||
abstract class SingleTableInheritanceEntity extends \Eloquent
|
||||
{
|
||||
/**
|
||||
* must be overridden and set to true in subclasses
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Toolkit;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
|
||||
/**
|
||||
* Class Navigation
|
||||
@ -11,7 +12,7 @@ class Navigation
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \Firefly\Exception\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
@ -39,7 +40,7 @@ class Navigation
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \Firefly\Exception\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function prev()
|
||||
{
|
||||
|
@ -1,49 +1,25 @@
|
||||
<?php
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
use LaravelBook\Ardent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $account_type_id
|
||||
* @property string $name
|
||||
* @property boolean $active
|
||||
* @property-read \AccountType $accountType
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Piggybank[] $piggybanks
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereAccountTypeId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereActive($value)
|
||||
* @method static \Account accountTypeIn($types)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\AccountMeta[] $accountMeta
|
||||
* @method static \Account withMeta()
|
||||
*/
|
||||
class Account extends Ardent
|
||||
class Account extends Eloquent
|
||||
{
|
||||
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
/**
|
||||
* Validation rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $rules
|
||||
= [
|
||||
= [
|
||||
'name' => ['required', 'between:1,100'],
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'account_type_id' => 'required|exists:account_types,id',
|
||||
'active' => 'required|boolean'
|
||||
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
||||
/**
|
||||
* Fillable fields.
|
||||
*
|
||||
@ -134,7 +110,7 @@ class Account extends Ardent
|
||||
}
|
||||
$meta = new AccountMeta;
|
||||
$meta->account()->associate($this);
|
||||
$meta->name = $fieldName;
|
||||
$meta->name = $fieldName;
|
||||
$meta->data = $fieldValue;
|
||||
$meta->save();
|
||||
|
||||
|
@ -1,26 +1,9 @@
|
||||
<?php
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* AccountMeta
|
||||
*
|
||||
* @property-read \Account $account
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereData($value)
|
||||
*/
|
||||
class AccountMeta extends Ardent
|
||||
class AccountMeta extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -1,25 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* AccountType
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property boolean $editable
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereType($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereEditable($value)
|
||||
*/
|
||||
class AccountType extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= [
|
||||
'type' => ['required', 'between:1,50', 'alphabasic'],
|
||||
|
@ -1,32 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Budget
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereClass($value)
|
||||
*/
|
||||
class Budget extends Component
|
||||
{
|
||||
protected $isSubclass = true;
|
||||
|
||||
public function limitrepetitions()
|
||||
{
|
||||
return $this->hasManyThrough('LimitRepetition', 'Limit','component_id');
|
||||
return $this->hasManyThrough('LimitRepetition', 'Limit', 'component_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,26 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereClass($value)
|
||||
*/
|
||||
class Category extends Component
|
||||
{
|
||||
protected $isSubclass = true;
|
||||
|
@ -1,28 +1,9 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Shared\SingleTableInheritanceEntity;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* Component
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereClass($value)
|
||||
*/
|
||||
class Component extends SingleTableInheritanceEntity
|
||||
{
|
||||
|
||||
@ -32,9 +13,11 @@ class Component extends SingleTableInheritanceEntity
|
||||
'name' => 'required|between:1,100|alphabasic',
|
||||
'class' => 'required',
|
||||
];
|
||||
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
||||
protected $fillable = ['name', 'user_id'];
|
||||
protected $subclassField = 'class';
|
||||
protected $table = 'components';
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||
|
@ -2,35 +2,12 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* Limit
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $component_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property float $amount
|
||||
* @property boolean $repeats
|
||||
* @property string $repeat_freq
|
||||
* @property-read \Budget $budget
|
||||
* @property-read \Component $component
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\LimitRepetition[] $limitrepetitions
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereComponentId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereAmount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereRepeats($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereRepeatFreq($value)
|
||||
*/
|
||||
class Limit extends Ardent
|
||||
class Limit extends Eloquent
|
||||
{
|
||||
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= [
|
||||
'component_id' => 'required|exists:components,id',
|
||||
|
@ -1,30 +1,11 @@
|
||||
<?php
|
||||
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* LimitRepetition
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $limit_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $enddate
|
||||
* @property float $amount
|
||||
* @property-read \Limit $limit
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereLimitId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereEnddate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereAmount($value)
|
||||
*/
|
||||
class LimitRepetition extends Ardent
|
||||
class LimitRepetition extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= [
|
||||
'limit_id' => 'required|exists:limits,id',
|
||||
@ -41,6 +22,14 @@ class LimitRepetition extends Ardent
|
||||
return ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function limit()
|
||||
{
|
||||
return $this->belongsTo('Limit');
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO see if this scope is still used.
|
||||
*
|
||||
@ -72,15 +61,6 @@ class LimitRepetition extends Ardent
|
||||
return floatval($sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function limit()
|
||||
{
|
||||
return $this->belongsTo('Limit');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||
*
|
||||
|
@ -1,51 +1,10 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* Piggybank
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property string $name
|
||||
* @property float $targetamount
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $targetdate
|
||||
* @property boolean $repeats
|
||||
* @property string $rep_length
|
||||
* @property integer $rep_every
|
||||
* @property integer $rep_times
|
||||
* @property string $reminder
|
||||
* @property integer $reminder_skip
|
||||
* @property integer $order
|
||||
* @property boolean $remind_me
|
||||
* @property-read \Account $account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankRepetition[] $piggybankrepetitions
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankEvent[] $piggybankevents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTargetamount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepeats($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepLength($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepEvery($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepTimes($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminder($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminderSkip($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereOrder($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRemindMe($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Reminder[] $reminders
|
||||
*/
|
||||
class Piggybank extends Ardent
|
||||
class Piggybank extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= ['account_id' => 'required|exists:accounts,id', // link to Account
|
||||
'name' => 'required|between:1,255', // name
|
||||
@ -126,11 +85,12 @@ class Piggybank extends Ardent
|
||||
return $this->currentRep;
|
||||
}
|
||||
if ($this->repeats == 0) {
|
||||
$rep = $this->piggybankrepetitions()->first(['piggybank_repetitions.*']);
|
||||
$rep = $this->piggybankrepetitions()->first(['piggybank_repetitions.*']);
|
||||
$this->currentRep = $rep;
|
||||
|
||||
return $rep;
|
||||
} else {
|
||||
$query = $this->piggybankrepetitions()->where(
|
||||
$query = $this->piggybankrepetitions()->where(
|
||||
function ($q) {
|
||||
|
||||
$q->where(
|
||||
@ -160,8 +120,8 @@ class Piggybank extends Ardent
|
||||
|
||||
}
|
||||
)
|
||||
->orderBy('startdate', 'ASC');
|
||||
$result = $query->first(['piggybank_repetitions.*']);
|
||||
->orderBy('startdate', 'ASC');
|
||||
$result = $query->first(['piggybank_repetitions.*']);
|
||||
$this->currentRep = $result;
|
||||
\Log::debug('Found relevant rep in currentRelevantRep(): ' . $result->id);
|
||||
|
||||
|
@ -1,31 +1,10 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* PiggybankEvent
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $piggybank_id
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property float $amount
|
||||
* @property integer $transaction_journal_id
|
||||
* @property-read \Piggybank $piggybank
|
||||
* @property-read \TransactionJournal $transactionJournal
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereAmount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereTransactionJournalId($value)
|
||||
*/
|
||||
class PiggybankEvent extends Ardent
|
||||
class PiggybankEvent extends Eloquent
|
||||
{
|
||||
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= [
|
||||
'piggybank_id' => 'required|exists:piggybanks,id',
|
||||
|
@ -1,31 +1,11 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use LaravelBook\Ardent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* PiggybankRepetition
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $piggybank_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $targetdate
|
||||
* @property float $currentamount
|
||||
* @property-read \Piggybank $piggybank
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCurrentamount($value)
|
||||
* @method static \PiggybankRepetition starts($date)
|
||||
* @method static \PiggybankRepetition targets($date)
|
||||
*/
|
||||
class PiggybankRepetition extends Ardent
|
||||
class PiggybankRepetition extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= [
|
||||
'piggybank_id' => 'required|exists:piggybanks,id',
|
||||
@ -66,11 +46,14 @@ class PiggybankRepetition extends Ardent
|
||||
return $this->belongsTo('Piggybank');
|
||||
}
|
||||
|
||||
public function scopeStarts(Builder $query, Carbon $date) {
|
||||
$query->where('startdate',$date->format('Y-m-d'));
|
||||
public function scopeStarts(Builder $query, Carbon $date)
|
||||
{
|
||||
$query->where('startdate', $date->format('Y-m-d'));
|
||||
}
|
||||
public function scopeTargets(Builder $query, Carbon $date) {
|
||||
$query->where('targetdate',$date->format('Y-m-d'));
|
||||
|
||||
public function scopeTargets(Builder $query, Carbon $date)
|
||||
{
|
||||
$query->where('targetdate', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,27 +1,9 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* Preference
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereData($value)
|
||||
*/
|
||||
class Preference extends Ardent
|
||||
class Preference extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= ['user_id' => 'required|exists:users,id', 'name' => 'required|between:1,255', 'data' => 'required'];
|
||||
|
||||
|
@ -1,43 +1,11 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* RecurringTransaction
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $match
|
||||
* @property float $amount_min
|
||||
* @property float $amount_max
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property boolean $active
|
||||
* @property boolean $automatch
|
||||
* @property string $repeat_freq
|
||||
* @property integer $skip
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereMatch($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMin($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMax($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAutomatch($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereRepeatFreq($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereSkip($value)
|
||||
*/
|
||||
class RecurringTransaction extends Ardent
|
||||
class RecurringTransaction extends Eloquent
|
||||
{
|
||||
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
@ -63,6 +31,7 @@ class RecurringTransaction extends Ardent
|
||||
|
||||
/**
|
||||
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function lastFoundMatch()
|
||||
|
@ -1,42 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* Reminder
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $enddate
|
||||
* @property boolean $active
|
||||
* @property boolean $notnow
|
||||
* @property integer $remindersable_id
|
||||
* @property string $remindersable_type
|
||||
* @property-read \ $remindersable
|
||||
* @property-read \User $user
|
||||
* @property mixed $data
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereNotnow($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableType($value)
|
||||
* @method static \Reminder dateIs($start, $end)
|
||||
*/
|
||||
class Reminder extends Ardent
|
||||
class Reminder extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $table = 'reminders';
|
||||
|
||||
public function getDataAttribute($value)
|
||||
{
|
||||
return json_decode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@ -56,6 +32,19 @@ class Reminder extends Ardent
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function scopeDateIs($query, Carbon $start, Carbon $end)
|
||||
{
|
||||
return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setDataAttribute($value)
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
@ -67,23 +56,4 @@ class Reminder extends Ardent
|
||||
}
|
||||
|
||||
|
||||
public function scopeDateIs($query, Carbon $start, Carbon $end)
|
||||
{
|
||||
return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'));
|
||||
}
|
||||
|
||||
public function getDataAttribute($value)
|
||||
{
|
||||
return json_decode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setDataAttribute($value)
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,44 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use LaravelBook\Ardent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* Transaction
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property integer $piggybank_id
|
||||
* @property integer $transaction_journal_id
|
||||
* @property string $description
|
||||
* @property float $amount
|
||||
* @property-read \Account $account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Piggybank $piggybank
|
||||
* @property-read \TransactionJournal $transactionJournal
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereTransactionJournalId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereAmount($value)
|
||||
* @method static \Transaction accountIs($account)
|
||||
* @method static \Transaction after($date)
|
||||
* @method static \Transaction before($date)
|
||||
* @method static \Transaction lessThan($amount)
|
||||
* @method static \Transaction moreThan($amount)
|
||||
* @method static \Transaction transactionTypes($types)
|
||||
*/
|
||||
class Transaction extends Ardent
|
||||
class Transaction extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
public static $rules
|
||||
= ['account_id' => 'numeric|required|exists:accounts,id',
|
||||
'piggybank_id' => 'numeric|exists:piggybanks,id',
|
||||
|
@ -1,24 +1,13 @@
|
||||
<?php
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* TransactionCurrency
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $code
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCode($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionJournals
|
||||
*/
|
||||
class TransactionCurrency extends Eloquent
|
||||
{
|
||||
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
@ -1,28 +1,15 @@
|
||||
<?php
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* TransactionGroup
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $relation
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereRelation($value)
|
||||
*/
|
||||
class TransactionGroup extends Ardent
|
||||
class TransactionGroup extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
public static $rules = [
|
||||
'relation' => 'required|in:balance'
|
||||
];
|
||||
public static $rules
|
||||
= [
|
||||
'relation' => 'required|in:balance'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
@ -1,77 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use LaravelBook\Ardent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* TransactionJournal
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $transaction_type_id
|
||||
* @property integer $recurring_transaction_id
|
||||
* @property integer $transaction_currency_id
|
||||
* @property string $description
|
||||
* @property boolean $completed
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankEvent[] $piggybankevents
|
||||
* @property-read \RecurringTransaction $recurringTransaction
|
||||
* @property-read \TransactionCurrency $transactionCurrency
|
||||
* @property-read \TransactionType $transactionType
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionTypeId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereRecurringTransactionId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionCurrencyId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCompleted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value)
|
||||
* @method static \TransactionJournal accountIs($account)
|
||||
* @method static \TransactionJournal after($date)
|
||||
* @method static \TransactionJournal before($date)
|
||||
* @method static \TransactionJournal defaultSorting()
|
||||
* @method static \TransactionJournal lessThan($amount)
|
||||
* @method static \TransactionJournal moreThan($amount)
|
||||
* @method static \TransactionJournal onDate($date)
|
||||
* @method static \TransactionJournal transactionTypes($types)
|
||||
* @method static \TransactionJournal withRelevantData()
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionGroup[] $transactiongroups
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
*/
|
||||
class TransactionJournal extends Ardent
|
||||
class TransactionJournal extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
public static $rules
|
||||
= ['transaction_type_id' => 'required|exists:transaction_types,id',
|
||||
@ -268,6 +204,11 @@ class TransactionJournal extends Ardent
|
||||
return $this->belongsTo('TransactionType');
|
||||
}
|
||||
|
||||
public function transactiongroups()
|
||||
{
|
||||
return $this->belongsToMany('TransactionGroup');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -286,9 +227,4 @@ class TransactionJournal extends Ardent
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
public function transactiongroups()
|
||||
{
|
||||
return $this->belongsToMany('TransactionGroup');
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,6 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
/**
|
||||
* TransactionRelation
|
||||
*
|
||||
*/
|
||||
class TransactionRelation extends Ardent {
|
||||
class TransactionRelation extends Eloquent
|
||||
{
|
||||
|
||||
}
|
@ -1,22 +1,11 @@
|
||||
<?php
|
||||
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* TransactionType
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionJournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereType($value)
|
||||
*/
|
||||
class TransactionType extends Ardent
|
||||
class TransactionType extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
|
@ -4,40 +4,12 @@ use Illuminate\Auth\Reminders\RemindableInterface;
|
||||
use Illuminate\Auth\Reminders\RemindableTrait;
|
||||
use Illuminate\Auth\UserInterface;
|
||||
use Illuminate\Auth\UserTrait;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $reset
|
||||
* @property string $remember_token
|
||||
* @property boolean $migrated
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Preference[] $preferences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\RecurringTransaction[] $recurringtransactions
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User wherePassword($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereReset($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Reminder[] $reminders
|
||||
*/
|
||||
class User extends Ardent implements UserInterface, RemindableInterface
|
||||
class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
{
|
||||
|
||||
use UserTrait, RemindableTrait;
|
||||
use UserTrait, RemindableTrait, ValidatingTrait;
|
||||
|
||||
|
||||
public static $rules
|
||||
|
@ -22,10 +22,10 @@
|
||||
},
|
||||
"require": {
|
||||
"laravel/framework": "4.2.*",
|
||||
"laravelbook/ardent": "~2.4",
|
||||
"davejamesmiller/laravel-breadcrumbs": "2.*",
|
||||
"grumpydictator/gchart": "dev-master",
|
||||
"michelf/php-markdown": "1.*"
|
||||
"michelf/php-markdown": "1.*",
|
||||
"watson/validating": "0.10.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "@stable",
|
||||
|
Loading…
Reference in New Issue
Block a user