2015-11-18 16:40:50 +02:00
|
|
|
<?php namespace app\Http\Controllers;
|
|
|
|
|
|
2015-11-18 18:08:37 +02:00
|
|
|
use Exception;
|
2015-11-18 16:40:50 +02:00
|
|
|
use Input;
|
|
|
|
|
use Session;
|
|
|
|
|
use Redirect;
|
|
|
|
|
use App\Services\ImportService;
|
|
|
|
|
use App\Http\Controllers\BaseController;
|
|
|
|
|
|
|
|
|
|
class ImportController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
public function __construct(ImportService $importService)
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
|
|
$this->importService = $importService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function doImport()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$files = [];
|
|
|
|
|
foreach (ImportService::$entityTypes as $entityType) {
|
|
|
|
|
if (Input::file("{$entityType}_file")) {
|
|
|
|
|
$files[$entityType] = Input::file("{$entityType}_file")->getRealPath();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$imported_files = $this->importService->import(Input::get('source'), $files);
|
2015-11-18 18:08:37 +02:00
|
|
|
Session::flash('message', trans('texts.imported_file').' - '.$imported_files);
|
|
|
|
|
} catch (Exception $exception) {
|
|
|
|
|
Session::flash('error', $exception->getMessage());
|
2015-11-18 16:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Redirect::to('/settings/'.ACCOUNT_IMPORT_EXPORT);
|
|
|
|
|
}
|
|
|
|
|
}
|