mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Code cleanup [skip ci]
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
//use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
//use Symfony\Component\Console\Input\InputOption;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Cleanup
|
* Class Cleanup
|
||||||
|
@@ -187,7 +187,7 @@ class AccountController extends BaseController
|
|||||||
return Redirect::route('accounts.create', e($data['what']))->withInput();
|
return Redirect::route('accounts.create', e($data['what']))->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store:
|
// store
|
||||||
$this->_repository->store($data);
|
$this->_repository->store($data);
|
||||||
Session::flash('success', 'Account "' . e($data['name']) . '" stored.');
|
Session::flash('success', 'Account "' . e($data['name']) . '" stored.');
|
||||||
if ($data['post_submit_action'] == 'store') {
|
if ($data['post_submit_action'] == 'store') {
|
||||||
|
@@ -149,7 +149,7 @@ class BillController extends BaseController
|
|||||||
return Redirect::route('bills.create')->withInput();
|
return Redirect::route('bills.create')->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store:
|
// store
|
||||||
$this->_repository->store($data);
|
$this->_repository->store($data);
|
||||||
Session::flash('success', 'Bill "' . e($data['name']) . '" stored.');
|
Session::flash('success', 'Bill "' . e($data['name']) . '" stored.');
|
||||||
if ($data['post_submit_action'] == 'store') {
|
if ($data['post_submit_action'] == 'store') {
|
||||||
|
@@ -179,7 +179,7 @@ class BudgetController extends BaseController
|
|||||||
return Redirect::route('budgets.create')->withInput();
|
return Redirect::route('budgets.create')->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store:
|
// store
|
||||||
$this->_repository->store($data);
|
$this->_repository->store($data);
|
||||||
Session::flash('success', 'Budget "' . e($data['name']) . '" stored.');
|
Session::flash('success', 'Budget "' . e($data['name']) . '" stored.');
|
||||||
if ($data['post_submit_action'] == 'store') {
|
if ($data['post_submit_action'] == 'store') {
|
||||||
|
@@ -116,7 +116,7 @@ class CategoryController extends BaseController
|
|||||||
return Redirect::route('categories.create')->withInput();
|
return Redirect::route('categories.create')->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store:
|
// store
|
||||||
$this->_repository->store($data);
|
$this->_repository->store($data);
|
||||||
Session::flash('success', 'Category "' . e($data['name']) . '" stored.');
|
Session::flash('success', 'Category "' . e($data['name']) . '" stored.');
|
||||||
if ($data['post_submit_action'] == 'store') {
|
if ($data['post_submit_action'] == 'store') {
|
||||||
|
@@ -145,7 +145,7 @@ class CurrencyController extends BaseController
|
|||||||
return Redirect::route('currency.create')->withInput();
|
return Redirect::route('currency.create')->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store:
|
// store
|
||||||
$this->_repository->store($data);
|
$this->_repository->store($data);
|
||||||
Session::flash('success', 'Currency "' . e($data['name']) . '" stored.');
|
Session::flash('success', 'Currency "' . e($data['name']) . '" stored.');
|
||||||
if ($data['post_submit_action'] == 'store') {
|
if ($data['post_submit_action'] == 'store') {
|
||||||
|
@@ -297,7 +297,7 @@ class PiggyBankController extends BaseController
|
|||||||
return Redirect::route('piggy_banks.create')->withInput();
|
return Redirect::route('piggy_banks.create')->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store:
|
// store
|
||||||
$piggyBank = $this->_repository->store($data);
|
$piggyBank = $this->_repository->store($data);
|
||||||
Event::fire('piggy_bank.store', [$piggyBank]); // new and used.
|
Event::fire('piggy_bank.store', [$piggyBank]); // new and used.
|
||||||
Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.');
|
Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.');
|
||||||
|
@@ -168,7 +168,7 @@ class RepeatedExpenseController extends BaseController
|
|||||||
return Redirect::route('repeated.create')->withInput();
|
return Redirect::route('repeated.create')->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store:
|
// store
|
||||||
$piggyBank = $this->_repository->store($data);
|
$piggyBank = $this->_repository->store($data);
|
||||||
Event::fire('piggy_bank.store', [$piggyBank]); // new and used.
|
Event::fire('piggy_bank.store', [$piggyBank]); // new and used.
|
||||||
Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.');
|
Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.');
|
||||||
|
@@ -94,7 +94,6 @@ class ReportController extends BaseController
|
|||||||
$budgets = $this->_repository->getBudgetsForMonth($date);
|
$budgets = $this->_repository->getBudgetsForMonth($date);
|
||||||
$categories = $this->_repository->getCategoriesForMonth($date, 10);
|
$categories = $this->_repository->getCategoriesForMonth($date, 10);
|
||||||
$accounts = $this->_repository->getAccountsForMonth($date);
|
$accounts = $this->_repository->getAccountsForMonth($date);
|
||||||
//$piggyBanks = $this->_repository->getPiggyBanksForMonth($date);
|
|
||||||
|
|
||||||
return View::make(
|
return View::make(
|
||||||
'reports.month',
|
'reports.month',
|
||||||
|
@@ -382,7 +382,7 @@ class TransactionController extends BaseController
|
|||||||
return Redirect::route('transactions.create', $data['what'])->withInput();
|
return Redirect::route('transactions.create', $data['what'])->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store:
|
// store
|
||||||
$journal = $this->_repository->store($data);
|
$journal = $this->_repository->store($data);
|
||||||
Event::fire('transactionJournal.store', [$journal, Input::get('piggy_bank_id')]); // new and used.
|
Event::fire('transactionJournal.store', [$journal, Input::get('piggy_bank_id')]); // new and used.
|
||||||
/*
|
/*
|
||||||
|
@@ -76,8 +76,6 @@ class UserController extends BaseController
|
|||||||
|
|
||||||
$user = $repository->register(Input::all());
|
$user = $repository->register(Input::all());
|
||||||
|
|
||||||
|
|
||||||
//$user = $this->user->register(Input::all());
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$email->sendVerificationMail($user);
|
$email->sendVerificationMail($user);
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CreateSessionTable
|
* Class CreateSessionTable
|
||||||
@@ -27,11 +28,11 @@ class CreateSessionTable extends Migration
|
|||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create(
|
Schema::create(
|
||||||
'sessions', function ($t) {
|
'sessions', function (Blueprint $table) {
|
||||||
$t->string('id')->unique();
|
$table->string('id')->unique();
|
||||||
$t->text('payload');
|
$table->text('payload');
|
||||||
$t->integer('last_activity');
|
$table->integer('last_activity');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -272,19 +272,6 @@ class ChangesForV321 extends Migration
|
|||||||
$this->dropComponentIdFromBudgetLimits(); // 16.
|
$this->dropComponentIdFromBudgetLimits(); // 16.
|
||||||
$this->expandCurrencyTable(); // 17.
|
$this->expandCurrencyTable(); // 17.
|
||||||
|
|
||||||
|
|
||||||
// $this->doRenameInLimitRepetitions();
|
|
||||||
// $this->doBudgetLimits();
|
|
||||||
// $this->doPiggyBankEvents();
|
|
||||||
// $this->doCreateCategoryTables();
|
|
||||||
// $this->doUpdateTransactionTable();
|
|
||||||
// $this->doDropCompRecurTable();
|
|
||||||
// $this->doDropCompTransTable();
|
|
||||||
// $this->doMoveBudgets();
|
|
||||||
// $this->doMoveCategories();
|
|
||||||
// $this->doMoveLimitReferences();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createBudgetTable()
|
public function createBudgetTable()
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\QueryException;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,23 +95,6 @@ class ChangesForV322 extends Migration
|
|||||||
Schema::rename('piggybank_repetitions', 'piggy_bank_repetitions');
|
Schema::rename('piggybank_repetitions', 'piggy_bank_repetitions');
|
||||||
Schema::rename('piggybanks', 'piggy_banks');
|
Schema::rename('piggybanks', 'piggy_banks');
|
||||||
|
|
||||||
// drop an invalid index (how, in sqlite?).
|
|
||||||
Schema::table(
|
|
||||||
'budget_limits', function (Blueprint $table) {
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// //$table->dropUnique('unique_ci_combi');
|
|
||||||
// } catch (QueryException $e) {
|
|
||||||
// echo 'Could not delete unique_ci_combi';
|
|
||||||
//
|
|
||||||
// } catch (PDOException $e) {
|
|
||||||
// echo 'Could not delete unique_ci_combi';
|
|
||||||
// } catch (Exception $e) {
|
|
||||||
// echo 'Could not delete unique_ci_combi';
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// recreate it the correct way:
|
// recreate it the correct way:
|
||||||
Schema::table(
|
Schema::table(
|
||||||
'budget_limits', function (Blueprint $table) {
|
'budget_limits', function (Blueprint $table) {
|
||||||
|
@@ -268,10 +268,10 @@ class TestContentSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function createPiggyBanks(User $user)
|
public function createPiggyBanks(User $user)
|
||||||
{
|
{
|
||||||
// account:
|
// account
|
||||||
$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
|
$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
|
||||||
|
|
||||||
// some dates:
|
// some dates
|
||||||
$endDate = clone $this->_startOfMonth;
|
$endDate = clone $this->_startOfMonth;
|
||||||
$nextYear = clone $this->_startOfMonth;
|
$nextYear = clone $this->_startOfMonth;
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ class TestContentSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function createRecurringTransactions(User $user)
|
public function createRecurringTransactions(User $user)
|
||||||
{
|
{
|
||||||
// account:
|
// account
|
||||||
$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
|
$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
|
||||||
|
|
||||||
$recurring = PiggyBank::create(
|
$recurring = PiggyBank::create(
|
||||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
|||||||
use FireflyIII\Database\CUD;
|
use FireflyIII\Database\CUD;
|
||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
@@ -224,18 +225,18 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
|||||||
|
|
||||||
// delete journals:
|
// delete journals:
|
||||||
$journals = \TransactionJournal::whereIn(
|
$journals = \TransactionJournal::whereIn(
|
||||||
'id', function ($query) use ($model) {
|
'id', function (Builder $query) use ($model) {
|
||||||
$query->select('transaction_journal_id')
|
$query->select('transaction_journal_id')
|
||||||
->from('transactions')->whereIn(
|
->from('transactions')->whereIn(
|
||||||
'account_id', function ($query) use ($model) {
|
'account_id', function (Builder $query) use ($model) {
|
||||||
$query
|
$query
|
||||||
->select('id')
|
->select('id')
|
||||||
->from('accounts')
|
->from('accounts')
|
||||||
->where(
|
->where(
|
||||||
function ($q) use ($model) {
|
function (Builder $q) use ($model) {
|
||||||
$q->where('id', $model->id);
|
$q->where('id', $model->id);
|
||||||
$q->orWhere(
|
$q->orWhere(
|
||||||
function ($q) use ($model) {
|
function (Builder $q) use ($model) {
|
||||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||||
// TODO magic number!
|
// TODO magic number!
|
||||||
$q->where('accounts.account_type_id', 3);
|
$q->where('accounts.account_type_id', 3);
|
||||||
@@ -273,10 +274,10 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
|||||||
|
|
||||||
// delete accounts:
|
// delete accounts:
|
||||||
\Account::where(
|
\Account::where(
|
||||||
function ($q) use ($model) {
|
function (Builder $q) use ($model) {
|
||||||
$q->where('id', $model->id);
|
$q->where('id', $model->id);
|
||||||
$q->orWhere(
|
$q->orWhere(
|
||||||
function ($q) use ($model) {
|
function (Builder $q) use ($model) {
|
||||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||||
// TODO magic number!
|
// TODO magic number!
|
||||||
$q->where('accounts.account_type_id', 3);
|
$q->where('accounts.account_type_id', 3);
|
||||||
|
@@ -10,6 +10,7 @@ use FireflyIII\Exception\NotImplementedException;
|
|||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Budget
|
* Class Budget
|
||||||
@@ -265,7 +266,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
return $this->getUser()
|
return $this->getUser()
|
||||||
->transactionjournals()
|
->transactionjournals()
|
||||||
->whereNotIn(
|
->whereNotIn(
|
||||||
'transaction_journals.id', function ($query) use ($start, $end) {
|
'transaction_journals.id', function (Builder $query) use ($start, $end) {
|
||||||
$query
|
$query
|
||||||
->select('transaction_journals.id')
|
->select('transaction_journals.id')
|
||||||
->from('transaction_journals')
|
->from('transaction_journals')
|
||||||
|
@@ -158,7 +158,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
$errors->add('description', 'Internal error: need to know type of transaction!');
|
$errors->add('description', 'Internal error: need to know type of transaction!');
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Amount:
|
* Amount
|
||||||
*/
|
*/
|
||||||
if (isset($model['amount']) && floatval($model['amount']) < 0.01) {
|
if (isset($model['amount']) && floatval($model['amount']) < 0.01) {
|
||||||
$errors->add('amount', 'Amount must be > 0.01');
|
$errors->add('amount', 'Amount must be > 0.01');
|
||||||
@@ -171,7 +171,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Budget:
|
* Budget
|
||||||
*/
|
*/
|
||||||
if (isset($model['budget_id']) && !ctype_digit($model['budget_id'])) {
|
if (isset($model['budget_id']) && !ctype_digit($model['budget_id'])) {
|
||||||
$errors->add('budget_id', 'Invalid budget');
|
$errors->add('budget_id', 'Invalid budget');
|
||||||
|
@@ -43,8 +43,6 @@ class FF3ServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
// FORMAT:
|
|
||||||
#$this->app->bind('Interface', 'Class');
|
|
||||||
$this->registerFacades();
|
$this->registerFacades();
|
||||||
$this->registerInterfaces();
|
$this->registerInterfaces();
|
||||||
$this->registerAliases();
|
$this->registerAliases();
|
||||||
@@ -88,10 +86,10 @@ class FF3ServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
public function registerInterfaces()
|
public function registerInterfaces()
|
||||||
{
|
{
|
||||||
// preferences:
|
// preferences
|
||||||
$this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');
|
$this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');
|
||||||
|
|
||||||
// registration and user mail:
|
// registration and user mail
|
||||||
$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
|
$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
|
||||||
|
|
||||||
// reports
|
// reports
|
||||||
|
@@ -365,24 +365,24 @@ class Report implements ReportInterface
|
|||||||
{
|
{
|
||||||
return \TransactionJournal::
|
return \TransactionJournal::
|
||||||
leftJoin(
|
leftJoin(
|
||||||
'transactions as t_from', function ($join) {
|
'transactions as t_from', function (JoinClause $join) {
|
||||||
$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
|
$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
|
->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'account_meta as acm_from', function ($join) {
|
'account_meta as acm_from', function (JoinClause $join) {
|
||||||
$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
|
$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'transactions as t_to', function ($join) {
|
'transactions as t_to', function (JoinClause $join) {
|
||||||
$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
|
$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
|
->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'account_meta as acm_to', function ($join) {
|
'account_meta as acm_to', function (JoinClause $join) {
|
||||||
$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
|
$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@@ -287,24 +287,24 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
{
|
{
|
||||||
return \TransactionJournal::
|
return \TransactionJournal::
|
||||||
leftJoin(
|
leftJoin(
|
||||||
'transactions as t_from', function ($join) {
|
'transactions as t_from', function (JoinClause $join) {
|
||||||
$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
|
$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
|
->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'account_meta as acm_from', function ($join) {
|
'account_meta as acm_from', function (JoinClause $join) {
|
||||||
$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
|
$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'transactions as t_to', function ($join) {
|
'transactions as t_to', function (JoinClause $join) {
|
||||||
$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
|
$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
|
->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'account_meta as acm_to', function ($join) {
|
'account_meta as acm_to', function (JoinClause $join) {
|
||||||
$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
|
$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@@ -4,6 +4,7 @@ namespace FireflyIII\Search;
|
|||||||
|
|
||||||
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Search
|
* Class Search
|
||||||
@@ -20,7 +21,7 @@ class Search
|
|||||||
public function searchAccounts(array $words)
|
public function searchAccounts(array $words)
|
||||||
{
|
{
|
||||||
return \Auth::user()->accounts()->with('accounttype')->where(
|
return \Auth::user()->accounts()->with('accounttype')->where(
|
||||||
function ($q) use ($words) {
|
function (Builder $q) use ($words) {
|
||||||
foreach ($words as $word) {
|
foreach ($words as $word) {
|
||||||
$q->orWhere('name', 'LIKE', '%' . e($word) . '%');
|
$q->orWhere('name', 'LIKE', '%' . e($word) . '%');
|
||||||
}
|
}
|
||||||
@@ -96,7 +97,7 @@ class Search
|
|||||||
public function searchTransactions(array $words)
|
public function searchTransactions(array $words)
|
||||||
{
|
{
|
||||||
return \Auth::user()->transactionjournals()->withRelevantData()->where(
|
return \Auth::user()->transactionjournals()->withRelevantData()->where(
|
||||||
function ($q) use ($words) {
|
function (Builder $q) use ($words) {
|
||||||
foreach ($words as $word) {
|
foreach ($words as $word) {
|
||||||
$q->orWhere('description', 'LIKE', '%' . e($word) . '%');
|
$q->orWhere('description', 'LIKE', '%' . e($word) . '%');
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,8 @@ class Steam
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO find a way to reliably remove cache entries for accounts.
|
||||||
|
*
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
@@ -23,24 +25,12 @@ class Steam
|
|||||||
*/
|
*/
|
||||||
public function balance(\Account $account, Carbon $date = null)
|
public function balance(\Account $account, Carbon $date = null)
|
||||||
{
|
{
|
||||||
\Log::debug('Now in Steam::balance() for account #' . $account->id . ' (' . $account->name . ')');
|
|
||||||
if (is_null($date)) {
|
|
||||||
$key = 'account.' . $account->id . '.latestBalance';
|
|
||||||
} else {
|
|
||||||
$key = 'account.' . $account->id . '.balanceOn' . $date->format('dmy');
|
|
||||||
}
|
|
||||||
if (\Cache::has($key)) {
|
|
||||||
// TODO find a way to reliably remove cache entries for accounts.
|
|
||||||
#return \Cache::get($key);
|
|
||||||
}
|
|
||||||
$date = is_null($date) ? Carbon::now() : $date;
|
$date = is_null($date) ? Carbon::now() : $date;
|
||||||
\Log::debug('Now reached the moment we fire the query.');
|
|
||||||
$balance = floatval(
|
$balance = floatval(
|
||||||
$account->transactions()->leftJoin(
|
$account->transactions()->leftJoin(
|
||||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||||
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
|
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
|
||||||
);
|
);
|
||||||
\Cache::put($key, $balance, 20160);
|
|
||||||
|
|
||||||
return $balance;
|
return $balance;
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ use Carbon\Carbon;
|
|||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PiggyBank
|
* Class PiggyBank
|
||||||
@@ -77,19 +78,19 @@ class PiggyBank extends Eloquent
|
|||||||
return $rep;
|
return $rep;
|
||||||
} else {
|
} else {
|
||||||
$query = $this->piggyBankRepetitions()->where(
|
$query = $this->piggyBankRepetitions()->where(
|
||||||
function ($q) {
|
function (Builder $q) {
|
||||||
|
|
||||||
$q->where(
|
$q->where(
|
||||||
function ($q) {
|
function (Builder $q) {
|
||||||
|
|
||||||
$q->where(
|
$q->where(
|
||||||
function ($q) {
|
function (Builder $q) {
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
$q->whereNull('startdate');
|
$q->whereNull('startdate');
|
||||||
$q->orWhere('startdate', '<=', $today->format('Y-m-d 00:00:00'));
|
$q->orWhere('startdate', '<=', $today->format('Y-m-d 00:00:00'));
|
||||||
}
|
}
|
||||||
)->where(
|
)->where(
|
||||||
function ($q) {
|
function (Builder $q) {
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
$q->whereNull('targetdate');
|
$q->whereNull('targetdate');
|
||||||
$q->orWhere('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
$q->orWhere('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||||
@@ -97,7 +98,7 @@ class PiggyBank extends Eloquent
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
)->orWhere(
|
)->orWhere(
|
||||||
function ($q) {
|
function (Builder $q) {
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
$q->where('startdate', '>=', $today->format('Y-m-d 00:00:00'));
|
$q->where('startdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||||
$q->where('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
$q->where('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||||
|
@@ -192,7 +192,7 @@ class TransactionJournal extends Eloquent
|
|||||||
public function scopeWithRelevantData(Builder $query)
|
public function scopeWithRelevantData(Builder $query)
|
||||||
{
|
{
|
||||||
$query->with(
|
$query->with(
|
||||||
['transactions' => function ($q) {
|
['transactions' => function (Builder $q) {
|
||||||
$q->orderBy('amount', 'ASC');
|
$q->orderBy('amount', 'ASC');
|
||||||
}, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
}, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
||||||
);
|
);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// models:
|
// models
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'account',
|
'account',
|
||||||
function ($value, $route) {
|
function ($value, $route) {
|
||||||
@@ -167,7 +167,6 @@ Route::group(
|
|||||||
|
|
||||||
// some date routes used for (well duh) date-based navigation.
|
// some date routes used for (well duh) date-based navigation.
|
||||||
Route::get('/prev', ['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);
|
Route::get('/prev', ['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);
|
||||||
//Route::get('/repair', ['uses' => 'HomeController@repair']);
|
|
||||||
Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);
|
Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);
|
||||||
Route::get('/jump/{range}', ['uses' => 'HomeController@rangeJump', 'as' => 'rangeJump']);
|
Route::get('/jump/{range}', ['uses' => 'HomeController@rangeJump', 'as' => 'rangeJump']);
|
||||||
|
|
||||||
@@ -268,7 +267,6 @@ Route::group(
|
|||||||
Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year']);
|
Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year']);
|
||||||
Route::get('/reports/{year}/{month}', ['uses' => 'ReportController@month', 'as' => 'reports.month']);
|
Route::get('/reports/{year}/{month}', ['uses' => 'ReportController@month', 'as' => 'reports.month']);
|
||||||
Route::get('/reports/budget/{year}/{month}', ['uses' => 'ReportController@budget', 'as' => 'reports.budget']);
|
Route::get('/reports/budget/{year}/{month}', ['uses' => 'ReportController@budget', 'as' => 'reports.budget']);
|
||||||
#Route::get('/reports/unbalanced/{year}/{month}', ['uses' => 'ReportController@unbalanced', 'as' => 'reports.unbalanced']);
|
|
||||||
|
|
||||||
// reminder controller
|
// reminder controller
|
||||||
Route::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);
|
Route::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);
|
||||||
|
@@ -68,7 +68,7 @@ App::down(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// forms:
|
// forms
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffText', function ($name, $value = null, array $options = []) {
|
'ffText', function ($name, $value = null, array $options = []) {
|
||||||
return \FireflyIII\Form\Form::ffText($name, $value, $options);
|
return \FireflyIII\Form\Form::ffText($name, $value, $options);
|
||||||
|
Reference in New Issue
Block a user