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