mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
New repair route [skip ci]
This commit is contained in:
@@ -17,52 +17,6 @@ class HomeController extends BaseController
|
|||||||
return Redirect::route('index');
|
return Redirect::route('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function repair() {
|
|
||||||
Component::where('class', 'Budget')->get()->each(
|
|
||||||
function (Component $c) {
|
|
||||||
$entry = [
|
|
||||||
'user_id' => $c->user_id,
|
|
||||||
'name' => $c->name
|
|
||||||
|
|
||||||
];
|
|
||||||
$budget = Budget::firstOrCreate($entry);
|
|
||||||
Log::debug('Migrated budget #' . $budget->id . ': ' . $budget->name);
|
|
||||||
// create entry in budget_transaction_journal
|
|
||||||
$connections = DB::table('component_transaction_journal')->where('component_id', $c->id)->get();
|
|
||||||
foreach ($connections as $connection) {
|
|
||||||
DB::table('budget_transaction_journal')->insert(
|
|
||||||
[
|
|
||||||
'budget_id' => $budget->id,
|
|
||||||
'transaction_journal_id' => $connection->transaction_journal_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
Component::where('class', 'Category')->get()->each(
|
|
||||||
function (Component $c) {
|
|
||||||
$entry = [
|
|
||||||
'user_id' => $c->user_id,
|
|
||||||
'name' => $c->name
|
|
||||||
|
|
||||||
];
|
|
||||||
$category = Category::firstOrCreate($entry);
|
|
||||||
Log::debug('Migrated category #' . $category->id . ': ' . $category->name);
|
|
||||||
// create entry in category_transaction_journal
|
|
||||||
$connections = DB::table('component_transaction_journal')->where('component_id', $c->id)->get();
|
|
||||||
foreach ($connections as $connection) {
|
|
||||||
DB::table('category_transaction_journal')->insert(
|
|
||||||
[
|
|
||||||
'category_id' => $category->id,
|
|
||||||
'transaction_journal_id' => $connection->transaction_journal_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return $this|\Illuminate\View\View
|
* @return $this|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
@@ -126,6 +80,22 @@ class HomeController extends BaseController
|
|||||||
return Redirect::back();
|
return Redirect::back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function repair()
|
||||||
|
{
|
||||||
|
BudgetLimit::get()->each(
|
||||||
|
function (BudgetLimit $bl) {
|
||||||
|
$component = Component::find($bl->component_id);
|
||||||
|
if ($component) {
|
||||||
|
$budget = Budget::whereName($component->name)->whereUserId($component->user_id)->first();
|
||||||
|
if ($budget) {
|
||||||
|
$bl->budget_id = $budget->id;
|
||||||
|
$bl->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ Route::bind(
|
|||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return LimitRepetition::
|
return LimitRepetition::
|
||||||
where('limit_repetitions.id', $value)->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')->leftJoin(
|
where('limit_repetitions.id', $value)->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')->leftJoin(
|
||||||
'components', 'components.id', '=', 'budget_limits.component_id'
|
'budgets', 'budgets.id', '=', 'budget_limits.budget_id'
|
||||||
)->where('components.class', 'Budget')->where('components.user_id', Auth::user()->id)->first(['limit_repetitions.*']);
|
)->where('budgets.user_id', Auth::user()->id)->first(['limit_repetitions.*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user