mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-25 06:51:08 +00:00
Some basic cleaning up.
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
//use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
//use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||||
|
|
||||||
class AccountController extends \BaseController {
|
class AccountController extends \BaseController
|
||||||
|
{
|
||||||
|
|
||||||
// public function __construct(ARI $accounts) {
|
// public function __construct(ARI $accounts) {
|
||||||
// $this->accounts = $accounts;
|
// $this->accounts = $accounts;
|
||||||
@@ -19,18 +20,15 @@ class AccountController extends \BaseController {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// /**
|
/**
|
||||||
// * Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
// *
|
*
|
||||||
// * @return Response
|
* @return Response
|
||||||
// */
|
*/
|
||||||
// public function create()
|
public function create()
|
||||||
// {
|
{
|
||||||
// if($this->accounts->count() == 0) {
|
return View::make('accounts.create');
|
||||||
// return View::make('accounts.create-first-time');
|
}
|
||||||
// }
|
|
||||||
// return View::make('accounts');
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
|
@@ -30,6 +30,8 @@ class MigrationController extends BaseController
|
|||||||
if (!$this->migration->validFile()) {
|
if (!$this->migration->validFile()) {
|
||||||
return View::make('error')->with('message', 'Invalid JSON content.');
|
return View::make('error')->with('message', 'Invalid JSON content.');
|
||||||
}
|
}
|
||||||
|
$this->migration->migrate();
|
||||||
|
return 'busy!';
|
||||||
}
|
}
|
||||||
|
|
||||||
// then, start migrating!
|
// then, start migrating!
|
||||||
|
@@ -13,6 +13,7 @@ class MigrationHelper implements MigrationHelperInterface
|
|||||||
{
|
{
|
||||||
protected $path;
|
protected $path;
|
||||||
protected $JSON;
|
protected $JSON;
|
||||||
|
protected $map = [];
|
||||||
|
|
||||||
public function loadFile($path)
|
public function loadFile($path)
|
||||||
{
|
{
|
||||||
@@ -38,4 +39,33 @@ class MigrationHelper implements MigrationHelperInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function migrate()
|
||||||
|
{
|
||||||
|
|
||||||
|
// create the accounts:
|
||||||
|
$this->_createAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function _createAccounts()
|
||||||
|
{
|
||||||
|
|
||||||
|
$accounts = App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
||||||
|
|
||||||
|
foreach ($this->JSON->accounts as $entry) {
|
||||||
|
// create account:
|
||||||
|
if ($entry->openingbalance == 0) {
|
||||||
|
$account = $accounts->store(['name' => $entry->name]);
|
||||||
|
} else {
|
||||||
|
$account = $accounts->storeWithInitialBalance(
|
||||||
|
['name' => $entry->name],
|
||||||
|
new Carbon($entry->openingbalancedate),
|
||||||
|
floatval($entry->openingbalance)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ($account) {
|
||||||
|
$this->map['accounts'][$entry->id] = $account->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -15,4 +15,6 @@ interface MigrationHelperInterface
|
|||||||
|
|
||||||
public function validFile();
|
public function validFile();
|
||||||
|
|
||||||
|
public function migrate();
|
||||||
|
|
||||||
}
|
}
|
@@ -1,24 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// basic home views:
|
// protected routes:
|
||||||
Route::get('/', ['uses' => 'HomeController@index','as' => 'index','before' => 'auth']);
|
Route::group(['before' => 'auth'], function () {
|
||||||
|
|
||||||
// login, register, logout:
|
// home controller
|
||||||
Route::get('/login',['uses' => 'UserController@login','as' => 'login','before' => 'guest']);
|
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
||||||
Route::get('/register',['uses' => 'UserController@register','as' => 'register','before' => 'guest']);
|
|
||||||
Route::get('/verify/{verification}',['uses' => 'UserController@verify','as' => 'verify','before' => 'guest']);
|
|
||||||
Route::get('/reset/{reset}',['uses' => 'UserController@reset','as' => 'reset','before' => 'guest']);
|
|
||||||
Route::get('/logout',['uses' => 'UserController@logout','as' => 'logout','before' => 'auth']);
|
|
||||||
Route::get('/remindme',['uses' => 'UserController@remindme','as' => 'remindme','before' => 'guest']);
|
|
||||||
Route::post('/login',['uses' => 'UserController@postLogin','before' => 'csrf|guest']);
|
|
||||||
Route::post('/register',['uses' => 'UserController@postRegister','before' => 'csrf|guest']);
|
|
||||||
Route::post('/remindme',['uses' => 'UserController@postRemindme','before' => 'csrf|guest']);
|
|
||||||
|
|
||||||
// profile (after login / logout)
|
// user controller
|
||||||
Route::get('/profile',['uses' => 'ProfileController@index','as' => 'profile','before' => 'auth']);
|
Route::get('/logout', ['uses' => 'UserController@logout', 'as' => 'logout']);
|
||||||
Route::get('/profile/change-password',['uses' => 'ProfileController@changePassword','as' => 'change-password','before' => 'auth']);
|
|
||||||
Route::post('/profile/change-password',['uses' => 'ProfileController@postChangePassword','before' => 'csrf|auth']);
|
|
||||||
|
|
||||||
// migrate controller:
|
//profile controller
|
||||||
Route::get('/migrate',['uses' => 'MigrationController@index','as' => 'migrate','before' => 'auth']);
|
Route::get('/profile', ['uses' => 'ProfileController@index', 'as' => 'profile']);
|
||||||
Route::post('/migrate',['uses' => 'MigrationController@postIndex','before' => 'csrf|auth']);
|
Route::get('/profile/change-password',['uses' => 'ProfileController@changePassword', 'as' => 'change-password']);
|
||||||
|
|
||||||
|
// migration controller
|
||||||
|
Route::get('/migrate', ['uses' => 'MigrationController@index', 'as' => 'migrate']);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// protected + csrf routes
|
||||||
|
Route::group(['before' => 'csrf|auth'], function () {
|
||||||
|
// profile controller
|
||||||
|
Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword']);
|
||||||
|
|
||||||
|
// migration controller
|
||||||
|
Route::post('/migrate', ['uses' => 'MigrationController@postIndex']);
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// guest routes:
|
||||||
|
Route::group(['before' => 'csrf|auth'], function () {
|
||||||
|
// user controller
|
||||||
|
Route::get('/login', ['uses' => 'UserController@login', 'as' => 'login']);
|
||||||
|
Route::get('/register', ['uses' => 'UserController@register', 'as' => 'register']);
|
||||||
|
Route::get('/verify/{verification}', ['uses' => 'UserController@verify', 'as' => 'verify']);
|
||||||
|
Route::get('/reset/{reset}', ['uses' => 'UserController@reset', 'as' => 'reset']);
|
||||||
|
Route::get('/remindme', ['uses' => 'UserController@remindme', 'as' => 'remindme']);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// guest + csrf routes:
|
||||||
|
Route::group(['before' => 'csrf|guest'], function () {
|
||||||
|
|
||||||
|
// user controller
|
||||||
|
Route::post('/login', ['uses' => 'UserController@postLogin']);
|
||||||
|
Route::post('/register', ['uses' => 'UserController@postRegister']);
|
||||||
|
Route::post('/remindme', ['uses' => 'UserController@postRemindme']);
|
||||||
|
}
|
||||||
|
);
|
Reference in New Issue
Block a user