Rename import/export, fix tests with parser
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Services\ImporterService;
|
||||
use App\Services\ImportService;
|
||||
|
||||
/**
|
||||
* Class ImportCsv
|
||||
@@ -21,9 +21,9 @@ class ImportCsv extends Command
|
||||
|
||||
/**
|
||||
* Import constructor.
|
||||
* @param ImporterService $importer
|
||||
* @param ImportService $importer
|
||||
*/
|
||||
public function __construct(ImporterService $importer)
|
||||
public function __construct(ImportService $importer)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->importer = $importer;
|
||||
|
||||
@@ -10,7 +10,7 @@ use App\Models\Enums\AircraftStatus;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Subfleet;
|
||||
use App\Repositories\AircraftRepository;
|
||||
use App\Services\ImporterService;
|
||||
use App\Services\ImportService;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
@@ -29,11 +29,11 @@ class AircraftController extends Controller
|
||||
/**
|
||||
* AircraftController constructor.
|
||||
* @param AircraftRepository $aircraftRepo
|
||||
* @param ImporterService $importSvc
|
||||
* @param ImportService $importSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AircraftRepository $aircraftRepo,
|
||||
ImporterService $importSvc
|
||||
ImportService $importSvc
|
||||
) {
|
||||
$this->aircraftRepo = $aircraftRepo;
|
||||
$this->importSvc = $importSvc;
|
||||
|
||||
@@ -9,7 +9,7 @@ use App\Models\Airport;
|
||||
use App\Models\Expense;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Services\ImporterService;
|
||||
use App\Services\ImportService;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||
@@ -28,11 +28,11 @@ class AirportController extends Controller
|
||||
|
||||
/**
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param ImporterService $importSvc
|
||||
* @param ImportService $importSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AirportRepository $airportRepo,
|
||||
ImporterService $importSvc
|
||||
ImportService $importSvc
|
||||
) {
|
||||
$this->airportRepo = $airportRepo;
|
||||
$this->importSvc = $importSvc;
|
||||
|
||||
@@ -15,10 +15,10 @@ use App\Repositories\FareRepository;
|
||||
use App\Repositories\FlightFieldRepository;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Repositories\SubfleetRepository;
|
||||
use App\Services\ExporterService;
|
||||
use App\Services\ExportService;
|
||||
use App\Services\FareService;
|
||||
use App\Services\FlightService;
|
||||
use App\Services\ImporterService;
|
||||
use App\Services\ImportService;
|
||||
use App\Support\Units\Time;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -51,7 +51,7 @@ class FlightController extends Controller
|
||||
* @param FlightFieldRepository $flightFieldRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param FlightService $flightSvc
|
||||
* @param ImporterService $importSvc
|
||||
* @param ImportService $importSvc
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -62,7 +62,7 @@ class FlightController extends Controller
|
||||
FlightFieldRepository $flightFieldRepo,
|
||||
FareService $fareSvc,
|
||||
FlightService $flightSvc,
|
||||
ImporterService $importSvc,
|
||||
ImportService $importSvc,
|
||||
SubfleetRepository $subfleetRepo
|
||||
) {
|
||||
$this->airlineRepo = $airlineRepo;
|
||||
@@ -319,7 +319,7 @@ class FlightController extends Controller
|
||||
*/
|
||||
public function export(Request $request)
|
||||
{
|
||||
$exporter = app(ExporterService::class);
|
||||
$exporter = app(ExportService::class);
|
||||
$path = storage_path('app/import/export_flight.csv');
|
||||
|
||||
$flights = $this->flightRepo->all();
|
||||
|
||||
@@ -15,7 +15,7 @@ use App\Repositories\RankRepository;
|
||||
use App\Repositories\SubfleetRepository;
|
||||
use App\Services\FareService;
|
||||
use App\Services\FleetService;
|
||||
use App\Services\ImporterService;
|
||||
use App\Services\ImportService;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
@@ -43,7 +43,7 @@ class SubfleetController extends Controller
|
||||
* @param FleetService $fleetSvc
|
||||
* @param FareRepository $fareRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param ImporterService $importSvc
|
||||
* @param ImportService $importSvc
|
||||
* @param RankRepository $rankRepo
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ class SubfleetController extends Controller
|
||||
FleetService $fleetSvc,
|
||||
FareRepository $fareRepo,
|
||||
FareService $fareSvc,
|
||||
ImporterService $importSvc,
|
||||
ImportService $importSvc,
|
||||
RankRepository $rankRepo,
|
||||
SubfleetRepository $subfleetRepo
|
||||
) {
|
||||
|
||||
@@ -90,6 +90,10 @@ class ImportExport
|
||||
$children = [];
|
||||
$kvp = explode('&', trim($query_str[1]));
|
||||
foreach ($kvp as $items) {
|
||||
if(!$items) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->kvpToArray($items, $children);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ use League\Csv\CharsetConverter;
|
||||
use League\Csv\Writer;
|
||||
|
||||
/**
|
||||
* Class ImporterService
|
||||
* Class ExportService
|
||||
* @package App\Services
|
||||
*/
|
||||
class ExporterService extends Service
|
||||
class ExportService extends Service
|
||||
{
|
||||
protected $flightRepo;
|
||||
|
||||
@@ -13,10 +13,10 @@ use App\Services\Import\SubfleetImporter;
|
||||
use League\Csv\Reader;
|
||||
|
||||
/**
|
||||
* Class ImporterService
|
||||
* Class ImportService
|
||||
* @package App\Services
|
||||
*/
|
||||
class ImporterService extends Service
|
||||
class ImportService extends Service
|
||||
{
|
||||
protected $flightRepo;
|
||||
|
||||
@@ -24,9 +24,7 @@ class ImporterService extends Service
|
||||
* ImporterService constructor.
|
||||
* @param FlightRepository $flightRepo
|
||||
*/
|
||||
public function __construct(
|
||||
FlightRepository $flightRepo
|
||||
) {
|
||||
public function __construct(FlightRepository $flightRepo) {
|
||||
$this->flightRepo = $flightRepo;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class ImporterTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
$this->importBaseClass = new \App\Interfaces\ImportExport();
|
||||
$this->importSvc = app(\App\Services\ImporterService::class);
|
||||
$this->importSvc = app(\App\Services\ImportService::class);
|
||||
$this->fareSvc = app(\App\Services\FareService::class);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class ImporterTest extends TestCase
|
||||
[
|
||||
'input' => 'Y?;F?price=1200',
|
||||
'expected' => [
|
||||
0 => 'Y',
|
||||
'Y' => [],
|
||||
'F' => [
|
||||
'price' => 1200
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user