Typeratings
This commit is contained in:
parent
a4564af309
commit
5e04d78275
@ -1,5 +1,6 @@
|
|||||||
<?php namespace GermanAirlinesVa\Schooling;
|
<?php namespace GermanAirlinesVa\Schooling;
|
||||||
|
|
||||||
|
use Config;
|
||||||
use System\Classes\PluginBase;
|
use System\Classes\PluginBase;
|
||||||
|
|
||||||
class Plugin extends PluginBase
|
class Plugin extends PluginBase
|
||||||
@ -11,4 +12,12 @@ class Plugin extends PluginBase
|
|||||||
public function registerSettings()
|
public function registerSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Config::set(
|
||||||
|
'database.connections.germanairlinesva_schooling',
|
||||||
|
Config::get('germanairlinesva.schooling::connection')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Relations
|
||||||
|
|
||||||
|
## Typerating
|
||||||
|
|
||||||
|
- HasMany AircraftTypes (External DB)
|
||||||
25
config/config.php
Normal file
25
config/config.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'connection' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'url' => env('DATABASE_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => 'germanairlinesva_schooling',
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => 'utf8mb4',
|
||||||
|
'collation' => 'utf8mb4_unicode_ci',
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => 'InnoDB',
|
||||||
|
'options' => extension_loaded('pdo_mysql')
|
||||||
|
? array_filter([
|
||||||
|
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
])
|
||||||
|
: [],
|
||||||
|
],
|
||||||
|
];
|
||||||
17
controllers/Typerating.php
Normal file
17
controllers/Typerating.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
|
use Backend\Classes\Controller;
|
||||||
|
use BackendMenu;
|
||||||
|
|
||||||
|
class Typerating 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
21
controllers/typerating/_list_toolbar.htm
Normal file
21
controllers/typerating/_list_toolbar.htm
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<div data-control="toolbar">
|
||||||
|
<a href="<?= Backend::url('germanairlinesva/schooling/typerating/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>
|
||||||
10
controllers/typerating/config_form.yaml
Normal file
10
controllers/typerating/config_form.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
name: Typerating
|
||||||
|
form: $/germanairlinesva/schooling/models/typerating/fields.yaml
|
||||||
|
modelClass: GermanAirlinesVa\Schooling\Models\Typerating
|
||||||
|
defaultRedirect: germanairlinesva/schooling/typerating
|
||||||
|
create:
|
||||||
|
redirect: 'germanairlinesva/schooling/typerating/update/:id'
|
||||||
|
redirectClose: germanairlinesva/schooling/typerating
|
||||||
|
update:
|
||||||
|
redirect: germanairlinesva/schooling/typerating
|
||||||
|
redirectClose: germanairlinesva/schooling/typerating
|
||||||
12
controllers/typerating/config_list.yaml
Normal file
12
controllers/typerating/config_list.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
list: $/germanairlinesva/schooling/models/typerating/columns.yaml
|
||||||
|
modelClass: GermanAirlinesVa\Schooling\Models\Typerating
|
||||||
|
title: Typerating
|
||||||
|
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/schooling/typerating/update/:id'
|
||||||
54
controllers/typerating/create.htm
Normal file
54
controllers/typerating/create.htm
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php Block::put('breadcrumb') ?>
|
||||||
|
<ul>
|
||||||
|
<li><a href="<?= Backend::url('germanairlinesva/schooling/typerating') ?>">Typerating</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/schooling/typerating') ?>"
|
||||||
|
><?= 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/schooling/typerating') ?>" class="btn btn-default"
|
||||||
|
><?= e(trans('backend::lang.form.return_to_list')) ?></a
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
<?php endif ?>
|
||||||
1
controllers/typerating/index.htm
Normal file
1
controllers/typerating/index.htm
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?= $this->listRender() ?>
|
||||||
20
controllers/typerating/preview.htm
Normal file
20
controllers/typerating/preview.htm
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php Block::put('breadcrumb') ?>
|
||||||
|
<ul>
|
||||||
|
<li><a href="<?= Backend::url('germanairlinesva/schooling/typerating') ?>">Typerating</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/schooling/typerating') ?>" class="btn btn-default oc-icon-chevron-left">
|
||||||
|
<?= e(trans('backend::lang.form.return_to_list')) ?>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
62
controllers/typerating/update.htm
Normal file
62
controllers/typerating/update.htm
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php Block::put('breadcrumb') ?>
|
||||||
|
<ul>
|
||||||
|
<li><a href="<?= Backend::url('germanairlinesva/schooling/typerating') ?>">Typerating</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/schooling/typerating') ?>"
|
||||||
|
><?= 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/schooling/typerating') ?>" class="btn btn-default"
|
||||||
|
><?= e(trans('backend::lang.form.return_to_list')) ?></a
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
<?php endif ?>
|
||||||
@ -3,4 +3,12 @@
|
|||||||
'name' => 'Schooling',
|
'name' => 'Schooling',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
],
|
],
|
||||||
|
'typeratings' => [
|
||||||
|
'name' => 'Typerating Name',
|
||||||
|
'price' => 'Price for exam',
|
||||||
|
],
|
||||||
|
'menu' => [
|
||||||
|
'main' => 'Schooling',
|
||||||
|
'typeratings' => 'Typeratings',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
32
models/Typerating.php
Normal file
32
models/Typerating.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php namespace GermanAirlinesVa\Schooling\Models;
|
||||||
|
|
||||||
|
use Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model
|
||||||
|
*/
|
||||||
|
class Typerating 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 = 'typeratings';
|
||||||
|
protected $connection = 'germanairlinesva_schooling';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Validation rules
|
||||||
|
*/
|
||||||
|
public $rules = ['name' => 'required', 'price' => 'required'];
|
||||||
|
|
||||||
|
public $hasMany = [
|
||||||
|
'aircraft_types' => 'GermanAirlinesVa\Fleet',
|
||||||
|
];
|
||||||
|
}
|
||||||
10
models/typerating/columns.yaml
Normal file
10
models/typerating/columns.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
columns:
|
||||||
|
id:
|
||||||
|
label: id
|
||||||
|
type: text
|
||||||
|
name:
|
||||||
|
label: name
|
||||||
|
type: text
|
||||||
|
price:
|
||||||
|
label: price
|
||||||
|
type: number
|
||||||
11
models/typerating/fields.yaml
Normal file
11
models/typerating/fields.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fields:
|
||||||
|
name:
|
||||||
|
label: 'germanairlinesva.schooling::lang.typeratings.name'
|
||||||
|
span: auto
|
||||||
|
required: 1
|
||||||
|
type: text
|
||||||
|
price:
|
||||||
|
label: 'germanairlinesva.schooling::lang.typeratings.price'
|
||||||
|
span: auto
|
||||||
|
required: 1
|
||||||
|
type: number
|
||||||
10
plugin.yaml
10
plugin.yaml
@ -4,3 +4,13 @@ plugin:
|
|||||||
author: 'German Airlines Va'
|
author: 'German Airlines Va'
|
||||||
icon: oc-icon-university
|
icon: oc-icon-university
|
||||||
homepage: ''
|
homepage: ''
|
||||||
|
navigation:
|
||||||
|
main-menu-item:
|
||||||
|
label: 'germanairlinesva.schooling::lang.menu.main'
|
||||||
|
url: /
|
||||||
|
icon: icon-university
|
||||||
|
sideMenu:
|
||||||
|
side-menu-item:
|
||||||
|
label: 'germanairlinesva.schooling::lang.menu.typeratings'
|
||||||
|
url: germanairlinesva/schooling/typerating
|
||||||
|
icon: icon-plane
|
||||||
|
|||||||
31
updates/builder_table_create_typeratings.php
Normal file
31
updates/builder_table_create_typeratings.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php namespace GermanAirlinesVa\Schooling\Updates;
|
||||||
|
|
||||||
|
use Schema;
|
||||||
|
use October\Rain\Database\Updates\Migration;
|
||||||
|
|
||||||
|
class BuilderTableCreateTyperatings extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('germanairlinesva_schooling')->create('typeratings', function ($table) {
|
||||||
|
$table->engine = 'InnoDB';
|
||||||
|
$table->bigIncrements('id')->unsigned();
|
||||||
|
$table->string('name');
|
||||||
|
$table->integer('price');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::connection('germanairlinesva_fleet')->table('aircraft_types', function ($table) {
|
||||||
|
$table
|
||||||
|
->foreign('typerating_id')
|
||||||
|
->references('id')
|
||||||
|
->on('germanairlinesva_schooling.typeratings');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('germanairlinesva_schooling')->disableForeignKeyConstraints();
|
||||||
|
Schema::connection('germanairlinesva_schooling')->dropIfExists('typeratings');
|
||||||
|
Schema::connection('germanairlinesva_schooling')->enableForeignKeyConstraints();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,2 +1,5 @@
|
|||||||
1.0.1:
|
1.0.1:
|
||||||
- Initialize plugin.
|
- 'Initialize plugin.'
|
||||||
|
1.0.2:
|
||||||
|
- 'Created table typeratings'
|
||||||
|
- builder_table_create_typeratings.php
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user