mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-30 12:43:57 -06:00
67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
|
|
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
|
|
|
/**
|
|
* Class PreferencesController
|
|
*/
|
|
class PreferencesController extends BaseController
|
|
{
|
|
protected $_accounts;
|
|
protected $_preferences;
|
|
|
|
/**
|
|
* @param ARI $accounts
|
|
* @param PHI $preferences
|
|
*/
|
|
public function __construct(ARI $accounts, PHI $preferences)
|
|
{
|
|
|
|
$this->_accounts = $accounts;
|
|
$this->_preferences = $preferences;
|
|
}
|
|
|
|
/**
|
|
* @return $this|\Illuminate\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
$accounts = $this->_accounts->getDefault();
|
|
|
|
$viewRange = $this->_preferences->get('viewRange', '1M');
|
|
$viewRangeValue = $viewRange->data;
|
|
|
|
// pref:
|
|
$frontpage = $this->_preferences->get('frontpageAccounts', []);
|
|
|
|
return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage)
|
|
->with('viewRange', $viewRangeValue);
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function postIndex()
|
|
{
|
|
|
|
// frontpage accounts
|
|
$frontpageAccounts = [];
|
|
foreach (Input::get('frontpageAccounts') as $id) {
|
|
$frontpageAccounts[] = intval($id);
|
|
}
|
|
$this->_preferences->set('frontpageAccounts', $frontpageAccounts);
|
|
|
|
// view range:
|
|
$this->_preferences->set('viewRange', Input::get('viewRange'));
|
|
// forget session values:
|
|
Session::forget('start');
|
|
Session::forget('end');
|
|
Session::forget('range');
|
|
|
|
Session::flash('success', 'Preferences saved!');
|
|
|
|
return Redirect::route('preferences');
|
|
}
|
|
|
|
}
|