mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Remove some middleware, fix cleanup [skip ci]
This commit is contained in:
parent
17f9bf0339
commit
11a494cacf
@ -39,7 +39,6 @@ class Kernel extends HttpKernel
|
||||
'range' => 'FireflyIII\Http\Middleware\Range',
|
||||
'cleanup' => 'FireflyIII\Http\Middleware\Cleanup',
|
||||
'reminders' => 'FireflyIII\Http\Middleware\Reminders',
|
||||
'piggybanks' => 'FireflyIII\Http\Middleware\PiggyBanks',
|
||||
|
||||
];
|
||||
|
||||
|
@ -153,94 +153,6 @@ class Cleanup
|
||||
}
|
||||
unset($set, $entry, $metadata);
|
||||
|
||||
// encrypt account virtual balance amount
|
||||
$set = Account::whereNull('virtual_balance_encrypted')->take(5)->get();
|
||||
/** @var Account $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->amount;
|
||||
$entry->virtual_balance = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
|
||||
// encrypt bill amount_min
|
||||
$set = Bill::whereNull('amount_min_encrypted')->take(5)->get();
|
||||
/** @var Bill $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->amount_min;
|
||||
$entry->amount_min = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
|
||||
// encrypt bill amount_max
|
||||
$set = Bill::whereNull('amount_max_encrypted')->take(5)->get();
|
||||
/** @var Bill $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->amount_max;
|
||||
$entry->amount_max = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
|
||||
// encrypt budget limit amount
|
||||
$set = BudgetLimit::whereNull('amount_encrypted')->take(5)->get();
|
||||
/** @var BudgetLimit $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->amount;
|
||||
$entry->amount = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
|
||||
// encrypt limit repetition amount
|
||||
$set = LimitRepetition::whereNull('amount_encrypted')->take(5)->get();
|
||||
/** @var LimitRepetition $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->amount;
|
||||
$entry->amount = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
|
||||
//encrypt piggy bank event amount
|
||||
$set = PiggyBankEvent::whereNull('amount_encrypted')->take(5)->get();
|
||||
/** @var PiggyBankEvent $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->amount;
|
||||
$entry->amount = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
|
||||
// encrypt piggy bank repetition currentamount
|
||||
$set = PiggyBankRepetition::whereNull('currentamount_encrypted')->take(5)->get();
|
||||
/** @var PiggyBankRepetition $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->currentamount;
|
||||
$entry->currentamount = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
|
||||
// encrypt piggy bank targetamount
|
||||
$set = PiggyBank::whereNull('targetamount_encrypted')->take(5)->get();
|
||||
/** @var PiggyBank $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->targetamount;
|
||||
$entry->targetamount = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
|
||||
//encrypt preference name
|
||||
$set = Preference::whereNull('name_encrypted')->take(5)->get();
|
||||
/** @var Preference $entry */
|
||||
@ -251,7 +163,8 @@ class Cleanup
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $name);
|
||||
//encrypt preference data (add field)
|
||||
|
||||
//encrypt preference data
|
||||
$set = Preference::whereNull('data_encrypted')->take(5)->get();
|
||||
/** @var Preference $entry */
|
||||
foreach ($set as $entry) {
|
||||
@ -262,16 +175,6 @@ class Cleanup
|
||||
}
|
||||
unset($set, $entry, $data);
|
||||
|
||||
// encrypt transaction amount
|
||||
$set = Transaction::whereNull('amount_encrypted')->take(5)->get();
|
||||
/** @var Transaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
$count++;
|
||||
$amount = $entry->amount;
|
||||
$entry->amount = $amount;
|
||||
$entry->save();
|
||||
}
|
||||
unset($set, $entry, $amount);
|
||||
}
|
||||
if ($count == 0 && $run) {
|
||||
Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false');
|
||||
|
@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Http\Middleware;
|
||||
|
||||
|
||||
use Closure;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class PiggyBanks
|
||||
*
|
||||
* @package FireflyIII\Http\Middleware
|
||||
*/
|
||||
class PiggyBanks
|
||||
{
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
*
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check() && !$request->isXmlHttpRequest()) {
|
||||
// get piggy banks without a repetition:
|
||||
/** @var Collection $set */
|
||||
$set = $this->auth->user()->piggybanks()
|
||||
->leftJoin('piggy_bank_repetitions', 'piggy_banks.id', '=', 'piggy_bank_repetitions.piggy_bank_id')
|
||||
->whereNull('piggy_bank_repetitions.id')
|
||||
->get(['piggy_banks.id', 'piggy_banks.startdate', 'piggy_banks.targetdate']);
|
||||
|
||||
/** @var PiggyBank $partialPiggy */
|
||||
foreach ($set as $partialPiggy) {
|
||||
$repetition = new PiggyBankRepetition;
|
||||
$repetition->piggyBank()->associate($partialPiggy);
|
||||
$repetition->startdate = $partialPiggy->startdate;
|
||||
$repetition->targetdate = $partialPiggy->targetdate;
|
||||
$repetition->currentamount = 0;
|
||||
$repetition->save();
|
||||
}
|
||||
unset($partialPiggy, $set, $repetition);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -199,7 +199,7 @@ Route::get('/routes', ['uses' => 'HomeController@routes', 'as' => 'routes']);
|
||||
* Home Controller
|
||||
*/
|
||||
Route::group(
|
||||
['middleware' => ['auth', 'range', 'reminders', 'piggybanks']], function () {
|
||||
['middleware' => ['auth', 'range', 'reminders']], function () {
|
||||
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index', 'middleware' => 'cleanup']);
|
||||
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
|
||||
Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
|
||||
|
Loading…
Reference in New Issue
Block a user