This commit is contained in:
Gogs 2021-06-03 17:00:35 +02:00
parent 42a9e2c8c7
commit 9fdfe9dfb1
20 changed files with 533 additions and 145 deletions

View File

@ -1,4 +1,32 @@
# TODO
# Relations
- Type Creat Form localization
- Remove design phase databaase connection in Schema and Model
## AircraftManufacturers
- HasMany AircraftType
## AircraftTypes
- BelongsTo AircraftManufacturers
- **TODO** BelongsTo Typeratings (External DB)
- HasMany Aircrafts
## Aircrafts
- BelongsTo AircraftTypes
- **TODO** BelongsTo Airports (External DB, Multiple)
---
# Todo
## General
- Remove design phase database connection in Schema and Model
## AircraftTypes
- Form Localization
## Aircrafts
- Form Localization

17
controllers/Aircrafts.php Normal file
View File

@ -0,0 +1,17 @@
<?php namespace GermanAirlinesVa\Fleet\Controllers;
use Backend\Classes\Controller;
use BackendMenu;
class Aircrafts extends Controller
{
public $implement = [ 'Backend\Behaviors\ListController', 'Backend\Behaviors\FormController' ];
public $listConfig = 'config_list.yaml';
public $formConfig = 'config_form.yaml';
public function __construct()
{
parent::__construct();
}
}

View File

@ -0,0 +1,18 @@
<div data-control="toolbar">
<a href="<?= Backend::url('germanairlinesva/fleet/aircrafts/create') ?>" class="btn btn-primary oc-icon-plus"><?= e(trans('backend::lang.form.create')) ?></a>
<button
class="btn btn-default oc-icon-trash-o"
disabled="disabled"
onclick="$(this).data('request-data', {
checked: $('.control-list').listWidget('getChecked')
})"
data-request="onDelete"
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked"
data-request-success="$(this).prop('disabled', true)"
data-stripe-load-indicator>
<?= e(trans('backend::lang.list.delete_selected')) ?>
</button>
</div>

View File

@ -0,0 +1,10 @@
name: Aircrafts
form: $/germanairlinesva/fleet/models/aircraft/fields.yaml
modelClass: GermanAirlinesVa\Fleet\Models\Aircraft
defaultRedirect: germanairlinesva/fleet/aircrafts
create:
redirect: 'germanairlinesva/fleet/aircrafts/update/:id'
redirectClose: germanairlinesva/fleet/aircrafts
update:
redirect: germanairlinesva/fleet/aircrafts
redirectClose: germanairlinesva/fleet/aircrafts

View File

@ -0,0 +1,12 @@
list: $/germanairlinesva/fleet/models/aircraft/columns.yaml
modelClass: GermanAirlinesVa\Fleet\Models\Aircraft
title: Aircrafts
noRecordsMessage: 'backend::lang.list.no_records'
showSetup: true
showCheckboxes: true
recordsPerPage: 20
toolbar:
buttons: list_toolbar
search:
prompt: 'backend::lang.list.search_prompt'
recordUrl: 'germanairlinesva/fleet/aircrafts/update/:id'

View File

@ -0,0 +1,46 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('germanairlinesva/fleet/aircrafts') ?>">Aircrafts</a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>
<?php if (!$this->fatalError): ?>
<?= Form::open(['class' => 'layout']) ?>
<div class="layout-row">
<?= $this->formRender() ?>
</div>
<div class="form-buttons">
<div class="loading-indicator-container">
<button
type="submit"
data-request="onSave"
data-hotkey="ctrl+s, cmd+s"
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
class="btn btn-primary">
<?= e(trans('backend::lang.form.create')) ?>
</button>
<button
type="button"
data-request="onSave"
data-request-data="close:1"
data-hotkey="ctrl+enter, cmd+enter"
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
class="btn btn-default">
<?= e(trans('backend::lang.form.create_and_close')) ?>
</button>
<span class="btn-text">
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('germanairlinesva/fleet/aircrafts') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
</span>
</div>
</div>
<?= Form::close() ?>
<?php else: ?>
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
<p><a href="<?= Backend::url('germanairlinesva/fleet/aircrafts') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
<?php endif ?>

View File

@ -0,0 +1 @@
<?= $this->listRender() ?>

View File

@ -0,0 +1,22 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('germanairlinesva/fleet/aircrafts') ?>">Aircrafts</a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>
<?php if (!$this->fatalError): ?>
<div class="form-preview">
<?= $this->formRenderPreview() ?>
</div>
<?php else: ?>
<p class="flash-message static error"><?= e($this->fatalError) ?></p>
<?php endif ?>
<p>
<a href="<?= Backend::url('germanairlinesva/fleet/aircrafts') ?>" class="btn btn-default oc-icon-chevron-left">
<?= e(trans('backend::lang.form.return_to_list')) ?>
</a>
</p>

View File

@ -0,0 +1,54 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('germanairlinesva/fleet/aircrafts') ?>">Aircrafts</a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>
<?php if (!$this->fatalError): ?>
<?= Form::open(['class' => 'layout']) ?>
<div class="layout-row">
<?= $this->formRender() ?>
</div>
<div class="form-buttons">
<div class="loading-indicator-container">
<button
type="submit"
data-request="onSave"
data-request-data="redirect:0"
data-hotkey="ctrl+s, cmd+s"
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
class="btn btn-primary">
<?= e(trans('backend::lang.form.save')) ?>
</button>
<button
type="button"
data-request="onSave"
data-request-data="close:1"
data-hotkey="ctrl+enter, cmd+enter"
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
class="btn btn-default">
<?= e(trans('backend::lang.form.save_and_close')) ?>
</button>
<button
type="button"
class="oc-icon-trash-o btn-icon danger pull-right"
data-request="onDelete"
data-load-indicator="<?= e(trans('backend::lang.form.deleting')) ?>"
data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')) ?>">
</button>
<span class="btn-text">
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('germanairlinesva/fleet/aircrafts') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
</span>
</div>
</div>
<?= Form::close() ?>
<?php else: ?>
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
<p><a href="<?= Backend::url('germanairlinesva/fleet/aircrafts') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
<?php endif ?>

View File

@ -14,5 +14,6 @@
'main' => 'GA Fleet',
'manufacturers' => 'Aircraft Manufacturers',
'types' => 'Aircraft Types',
'aircrafts' => 'Aircrafts',
],
];

33
models/Aircraft.php Normal file
View File

@ -0,0 +1,33 @@
<?php namespace GermanAirlinesVa\Fleet\Models;
use Model;
/**
* Model
*/
class Aircraft extends Model
{
use \October\Rain\Database\Traits\Validation;
/*
* Disable timestamps by default.
* Remove this line if timestamps are defined in the database table.
*/
public $timestamps = false;
/**
* @var string The database table used by the model.
*/
//public $table = 'germanairlinesva_fleet_aircrafts';
public $table = 'aircrafts';
protected $connection = 'germanairlinesva_fleet';
/**
* @var array Validation rules
*/
public $rules = [];
public $belongsTo = [
'aircraft_type' => 'GermanAirlinesVa\Fleet\Models\AircraftType',
];
}

View File

@ -26,4 +26,8 @@ class AircraftManufacturer extends Model
* @var array Validation rules
*/
public $rules = [];
public $hasMany = [
'aircraft_types' => 'GermanAirlinesVa\Fleet\Models\AircraftType',
];
}

View File

@ -30,4 +30,8 @@ class AircraftType extends Model
public $belongsTo = [
'aircraft_manufacturer' => 'GermanAirlinesVa\Fleet\Models\AircraftManufacturer',
];
public $hasMany = [
'aircrafts' => 'GermanAirlinesVa\Fleet\Models\Aircraft',
];
}

View File

@ -0,0 +1,49 @@
columns:
id:
label: id
type: text
aircraft_type_id:
label: aircraft_type_id
type: text
home_airport_id:
label: home_airport_id
type: text
airport_id:
label: airport_id
type: text
name:
label: name
type: text
registration:
label: registration
type: text
in_use:
label: in_use
type: text
total_miles:
label: total_miles
type: text
total_fuel:
label: total_fuel
type: text
total_flight_time:
label: total_flight_time
type: text
total_expenses:
label: total_expenses
type: text
current_check:
label: current_check
type: text
last_a_check:
label: last_a_check
type: text
last_b_check:
label: last_b_check
type: text
last_c_check:
label: last_c_check
type: text
last_d_check:
label: last_d_check
type: text

View File

@ -0,0 +1,23 @@
fields:
aircraft_type:
label: Type
nameFrom: type
descriptionFrom: description
span: auto
required: 1
type: relation
registration:
label: Registration
span: auto
required: 1
type: text
name:
label: Name
span: auto
required: 1
type: text
home_airport_id:
label: 'Home Base'
span: auto
required: 1
type: number

View File

@ -1,141 +1,137 @@
tabs:
fields:
aircraft_manufacturer:
label: Manufacturer
nameFrom: name
descriptionFrom: description
span: auto
required: 1
type: relation
tab: Operational
typerating_id:
label: Typerating
span: auto
required: 1
type: number
tab: Operational
only_charter:
label: 'Charter Only'
options:
'No': 'no'
'Yes': 'yes'
showSearch: true
span: auto
required: 1
type: dropdown
tab: Operational
type:
label: Type
span: auto
required: 1
type: text
tab: Operational
simbrief_type:
label: 'SimBrief Type'
span: auto
required: 1
type: text
tab: Operational
dom:
label: DOM
span: auto
required: 1
type: number
tab: Weights
mpld:
label: 'Max Payload'
span: auto
required: 1
type: number
tab: Weights
mzfm:
label: 'Max ZFM'
span: auto
required: 1
type: number
tab: Weights
fuel_capacity:
label: 'Fuel Capacity'
span: auto
required: 1
type: number
tab: Weights
mtom:
label: 'Max TOM'
span: auto
required: 1
type: number
tab: Weights
mlam:
label: 'Max LAM'
span: auto
required: 1
type: number
tab: Weights
description:
label: Description
size: large
span: auto
required: 1
type: richeditor
tab: Informational
wingspan:
label: Wingspan
span: auto
required: 1
type: text
tab: Informational
length:
label: Length
span: auto
required: 1
type: text
tab: Informational
cruise_speed:
label: 'Cruise Speed'
span: auto
required: 1
type: text
tab: Informational
range:
label: Range
span: auto
required: 1
type: text
tab: Informational
engines:
label: Engines
span: auto
required: 1
type: text
tab: Informational
max_fl:
label: 'Max FL'
span: auto
required: 1
type: number
tab: Informational
capacity_flight_crew:
label: 'Flight Crew'
span: auto
required: 1
type: number
tab: Informational
capacity_cabin_crew:
label: 'Cabin Crew'
span: auto
required: 1
type: number
tab: Informational
capacity_passengers:
label: Passengers
span: auto
required: 1
type: number
tab: Informational
capacity_cargo:
label: Cargo
span: auto
required: 1
type: number
tab: Informational
fields:
aircraft_manufacturer:
label: Manufacturer
nameFrom: name
descriptionFrom: description
span: auto
required: 1
type: relation
tab: Operational
typerating_id:
label: Typerating
span: auto
required: 1
type: number
tab: Operational
only_charter:
label: 'Charter Only'
span: auto
required: 1
type: switch
tab: Operational
type:
label: Type
span: auto
required: 1
type: text
tab: Operational
simbrief_type:
label: 'SimBrief Type'
span: auto
required: 1
type: text
tab: Operational
dom:
label: DOM
span: auto
required: 1
type: number
tab: Weights
mpld:
label: 'Max Payload'
span: auto
required: 1
type: number
tab: Weights
mzfm:
label: 'Max ZFM'
span: auto
required: 1
type: number
tab: Weights
fuel_capacity:
label: 'Fuel Capacity'
span: auto
required: 1
type: number
tab: Weights
mtom:
label: 'Max TOM'
span: auto
required: 1
type: number
tab: Weights
mlam:
label: 'Max LAM'
span: auto
required: 1
type: number
tab: Weights
description:
label: Description
size: large
span: auto
required: 1
type: richeditor
tab: Informational
wingspan:
label: Wingspan
span: auto
required: 1
type: text
tab: Informational
length:
label: Length
span: auto
required: 1
type: text
tab: Informational
cruise_speed:
label: 'Cruise Speed'
span: auto
required: 1
type: text
tab: Informational
range:
label: Range
span: auto
required: 1
type: text
tab: Informational
engines:
label: Engines
span: auto
required: 1
type: text
tab: Informational
max_fl:
label: 'Max FL'
span: auto
required: 1
type: number
tab: Informational
capacity_flight_crew:
label: 'Flight Crew'
span: auto
required: 1
type: number
tab: Informational
capacity_cabin_crew:
label: 'Cabin Crew'
span: auto
required: 1
type: number
tab: Informational
capacity_passengers:
label: Passengers
span: auto
required: 1
type: number
tab: Informational
capacity_cargo:
label: Cargo
span: auto
required: 1
type: number
tab: Informational

View File

@ -18,3 +18,7 @@ navigation:
label: 'germanairlinesva.fleet::lang.menu.types'
url: germanairlinesva/fleet/aircrafttypes
icon: icon-paper-plane
side-menu-item3:
label: 'germanairlinesva.fleet::lang.menu.aircrafts'
url: germanairlinesva/fleet/aircrafts
icon: icon-plane

View File

@ -19,10 +19,10 @@ class BuilderTableCreateGermanAirlinesVaAircraftTypes extends Migration
->on('aircraft_manufacturers');
$table->bigInteger('typerating_id')->unsigned();
//$table
// ->foreign('typerating_manufacturer_id')
// ->foreign('typerating_id')
// ->references('id')
// ->on('typeratings');
$table->enum('only_charter', ['yes', 'no']);
$table->boolean('only_charter');
$table->string('type');
$table->text('description');
$table->string('simbrief_type');

View File

@ -0,0 +1,64 @@
<?php namespace GermanAirlinesVa\Fleet\Updates;
use DB;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateGermanAirlinesVaFleetAircrafts extends Migration
{
public function up()
{
Schema::connection('germanairlinesva_fleet')->create('aircrafts', function ($table) {
//Schema::create('germanairlinesva_fleet_aircrafts', function ($table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->bigInteger('aircraft_type_id')->unsigned();
$table
->foreign('aircraft_type_id')
->references('id')
->on('aircraft_types');
$table->bigInteger('home_airport_id')->unsigned();
//$table
// ->foreign('home_airport_id')
// ->references('id')
// ->on('airports');
$table
->bigInteger('airport_id')
->unsigned()
->nullable();
//$table
// ->foreign('airport_id')
// ->references('id')
// ->on('airports');
$table->string('name');
$table->string('registration');
$table->boolean('in_use')->default(true);
$table
->double('total_miles')
->unsigned()
->default(0);
$table
->double('total_fuel')
->unsigned()
->default(0);
$table
->double('total_flight_time')
->unsigned()
->default(0);
$table
->double('total_expenses')
->unsigned()
->default(0);
$table->enum('current_check', ['a', 'b', 'c', 'd'])->nullable();
$table->datetime('last_a_check')->default(DB::raw('NOW()'));
$table->datetime('last_b_check')->default(DB::raw('NOW()'));
$table->datetime('last_c_check')->default(DB::raw('NOW()'));
$table->datetime('last_d_check')->default(DB::raw('NOW()'));
});
}
public function down()
{
Schema::connection('germanairlinesva_fleet')->dropIfExists('aircrafts');
//Schema::dropIfExists('germanairlinesva_fleet_aircrafts');
}
}

View File

@ -5,3 +5,5 @@
- builder_table_create_aircraft_manufacturers.php
- 'Created table aircraft_types'
- builder_table_create_aircraft_types.php
- 'Created table aircrafts'
- builder_table_create_aircrafts.php