mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-22 22:43:20 -06:00
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Firefly\Storage\Budget\BudgetRepositoryInterface as BRI;
|
|
use Firefly\Storage\Limit\LimitRepositoryInterface as LRI;
|
|
|
|
class LimitController extends BaseController
|
|
{
|
|
|
|
protected $_budgets;
|
|
protected $_limits;
|
|
|
|
public function __construct(BRI $budgets, LRI $limits)
|
|
{
|
|
$this->_budgets = $budgets;
|
|
$this->_limits = $limits;
|
|
View::share('menu', 'budgets');
|
|
|
|
}
|
|
|
|
public function create($budgetId = null)
|
|
{
|
|
$periods = [
|
|
'weekly' => 'A week',
|
|
'monthly' => 'A month',
|
|
'quarterly' => 'A quarter',
|
|
'half-year' => 'Six months',
|
|
'yearly' => 'A year',
|
|
];
|
|
|
|
$budget = $this->_budgets->find($budgetId);
|
|
$budget_id = is_null($budget) ? null : $budget->id;
|
|
$budgets = $this->_budgets->getAsSelectList();
|
|
return View::make('limits.create')->with('budgets', $budgets)->with('budget_id', $budget_id)->with(
|
|
'periods', $periods
|
|
);
|
|
}
|
|
|
|
public function store()
|
|
{
|
|
// find a limit with these properties, as we might already have one:
|
|
$limit = $this->_limits->store(Input::all());
|
|
if ($limit->id) {
|
|
return Redirect::route('budgets.index');
|
|
} else {
|
|
return Redirect::route('budgets.limits.create')->withInput();
|
|
}
|
|
}
|
|
|
|
}
|