YAML table exporter
This commit is contained in:
44
app/Console/Commands/YamlExport.php
Normal file
44
app/Console/Commands/YamlExport.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Services\DatabaseService;
|
||||
use DB;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class YamlExport extends BaseCommand
|
||||
{
|
||||
protected $signature = 'phpvms:export {tables*}';
|
||||
protected $description = 'YAML table export';
|
||||
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$tables = $this->argument('tables');
|
||||
if(empty($tables)) {
|
||||
$this->error('No tables specified');
|
||||
exit();
|
||||
}
|
||||
|
||||
$export_tables = [];
|
||||
foreach($tables as $table) {
|
||||
$export_tables[$table] = [];
|
||||
|
||||
$rows = DB::table($table)->get();
|
||||
foreach($rows as $row) {
|
||||
$export_tables[$table][] = (array) $row;
|
||||
}
|
||||
}
|
||||
|
||||
$yaml = Yaml::dump($export_tables, 4, 2);
|
||||
print($yaml);
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,8 @@ pireps:
|
||||
dpt_airport_id: KAUS
|
||||
arr_airport_id: KJFK
|
||||
flight_time: 180 # 6 hours
|
||||
state: 1
|
||||
state: 2
|
||||
status: 0
|
||||
route: KAUS SID TNV J87 IAH J2 LCH J22 MEI J239 ATL J52 AJFEB J14 BYJAC Q60 JAXSN J14 COLIN J61 HUBBS J55 SIE STAR KJFK
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
@@ -426,3 +427,119 @@ pirep_comments:
|
||||
comment: Another comment
|
||||
created_at: now
|
||||
updated_at: now
|
||||
|
||||
journals:
|
||||
- id: '1'
|
||||
ledger_id: null
|
||||
balance: '7965000'
|
||||
currency: USD
|
||||
morphed_type: App\Models\Airline
|
||||
morphed_id: '1'
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
|
||||
journal_transactions:
|
||||
- id: d2875dd2-e329-4d75-9883-120ef88f343a
|
||||
transaction_group: fares
|
||||
journal_id: '1'
|
||||
credit: '6000000'
|
||||
debit: '0'
|
||||
currency: USD
|
||||
memo: 'Fares Y300; price:200, cost: 0'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
post_date: '2018-03-02 03:31:59'
|
||||
deleted_at: null
|
||||
- id: 3912bedb-138e-47f4-9a1f-bcd29c3c00ad
|
||||
transaction_group: fares
|
||||
journal_id: '1'
|
||||
credit: '1100000'
|
||||
debit: '0'
|
||||
currency: USD
|
||||
memo: 'Fares B10; price:1100, cost: 0'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
post_date: '2018-03-02 03:31:59'
|
||||
deleted_at: null
|
||||
- id:: 55bbc2b8-646e-4d07-88d4-54c11c721f35
|
||||
transaction_group: fares
|
||||
journal_id: '1'
|
||||
credit: '1000000'
|
||||
debit: '0'
|
||||
currency: USD
|
||||
memo: 'Fares F10; price:1000, cost: 0'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
post_date: '2018-03-02 03:31:59'
|
||||
deleted_at: null
|
||||
- id:: d9a353ea-5e40-4c7c-b976-305b89957185
|
||||
transaction_group: expenses
|
||||
journal_id: '1'
|
||||
credit: null
|
||||
debit: '10000'
|
||||
currency: USD
|
||||
memo: 'Expense: Per-Flight (no muliplier)'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
post_date: '2018-03-02 03:31:59'
|
||||
deleted_at: null
|
||||
- id:: 9d1f321a-7fdb-402b-af90-ebf6cd5717a3
|
||||
transaction_group: expenses
|
||||
journal_id: '1'
|
||||
credit: null
|
||||
debit: '10000'
|
||||
currency: USD
|
||||
memo: 'Expense: Per-Flight (multiplier)'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
post_date: '2018-03-02 03:31:59'
|
||||
deleted_at: null
|
||||
- id:: 7583cd5f-e75d-472d-b913-af724dc30f30
|
||||
transaction_group: expenses
|
||||
journal_id: '1'
|
||||
credit: null
|
||||
debit: '20000'
|
||||
currency: USD
|
||||
memo: 'Expense: Per-Flight (multiplier, on airline)'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
post_date: '2018-03-02 03:31:59'
|
||||
deleted_at: null
|
||||
- id:: 9cf2fe46-124c-40a1-8cb8-1d1940c18704
|
||||
transaction_group: expenses
|
||||
journal_id: '1'
|
||||
credit: null
|
||||
debit: '20000'
|
||||
currency: USD
|
||||
memo: 'Expense: Per-Flight (multiplier, on airline)'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
post_date: '2018-03-02 03:31:59'
|
||||
deleted_at: null
|
||||
- id:: 200af4e2-50fd-43f9-bcf3-93cc29800679
|
||||
transaction_group: ground_handling
|
||||
journal_id: '1'
|
||||
credit: null
|
||||
debit: '75000'
|
||||
currency: USD
|
||||
memo: 'Ground handling'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-02 03:31:59'
|
||||
updated_at: '2018-03-02 03:31:59'
|
||||
post_date: '2018-03-02 03:31:59'
|
||||
deleted_at: null
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<table class="table table-hover table-responsive" id="aircrafts-table">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th style="text-align: center;">Registration</th>
|
||||
<th>Subfleet</th>
|
||||
<th style="text-align: center;">Location</th>
|
||||
{{--<th style="text-align: center;">ICAO</th>--}}
|
||||
<th style="text-align: center;">Registration</th>
|
||||
<th style="text-align: center;">Hours</th>
|
||||
<th style="text-align: center;">Active</th>
|
||||
<th style="text-align: right;"></th>
|
||||
@@ -13,6 +12,7 @@
|
||||
@foreach($aircraft as $ac)
|
||||
<tr>
|
||||
<td><a href="{!! route('admin.aircraft.edit', [$ac->id]) !!}">{!! $ac->name !!}</a></td>
|
||||
<td style="text-align: center;">{!! $ac->registration !!}</td>
|
||||
<td>
|
||||
@if($ac->subfleet_id && $ac->subfleet)
|
||||
<a href="{!! route('admin.subfleets.edit', [$ac->subfleet_id]) !!}">
|
||||
@@ -22,10 +22,7 @@
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
|
||||
<td style="text-align: center;">{!! $ac->airport_id !!}</td>
|
||||
|
||||
<td style="text-align: center;">{!! $ac->registration !!}</td>
|
||||
<td style="text-align: center;">
|
||||
{!! Utils::minutesToTimeString($ac->flight_hours) !!}
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user