firefly-iii/app/controllers/MigrationController.php

40 lines
967 B
PHP
Raw Normal View History

<?php
2014-06-30 03:47:14 -05:00
use Firefly\Helper\Migration\MigrationHelperInterface as MHI;
2014-06-30 03:47:14 -05:00
class MigrationController extends BaseController
{
protected $migration;
public function __construct(MHI $migration)
{
$this->migration = $migration;
View::share('menu', 'home');
}
public function index()
{
return View::make('migrate.index');
}
public function postIndex()
{
if (Input::hasFile('exportFile')) {
// get content:
$file = Input::file('exportFile');
$path = $file->getRealPath();
$this->migration->loadFile($path);
if (!$this->migration->validFile()) {
return View::make('error')->with('message', 'Invalid JSON content.');
}
2014-07-04 04:39:21 -05:00
$this->migration->migrate();
return Redirect::route('index');
2014-06-30 03:47:14 -05:00
} else {
return View::make('error')->with('message', 'No file selected');
2014-06-30 03:47:14 -05:00
}
}
}