change ref_class to ref_model

This commit is contained in:
Nabeel Shahzad 2018-04-01 14:32:01 -05:00
parent 0bed38c78b
commit 793b3e7134
31 changed files with 211 additions and 211 deletions

View File

@ -7,7 +7,7 @@ $factory->define(App\Models\Award::class, function (Faker $faker) {
'id' => null,
'name' => $faker->name,
'description' => $faker->text(10),
'ref_class' => null,
'ref_class_params' => null,
'ref_model' => null,
'ref_model_params' => null,
];
});

View File

@ -11,8 +11,8 @@ $factory->define(App\Models\Expense::class, function (Faker $faker) {
'amount' => $faker->randomFloat(2, 100, 1000),
'type' => ExpenseType::FLIGHT,
'multiplier' => false,
'ref_class' => \App\Models\Expense::class,
'ref_class_id' => null,
'ref_model' => \App\Models\Expense::class,
'ref_model_id' => null,
'active' => true,
];
});

View File

@ -21,13 +21,13 @@ class CreateAwardsTable extends Migration
# ref fields are expenses tied to some model object
# EG, the airports has an internal expense for gate costs
$table->string('ref_class')->nullable();
$table->text('ref_class_params')->nullable();
#$table->string('ref_class_id', 36)->nullable();
$table->string('ref_model')->nullable();
$table->text('ref_model_params')->nullable();
#$table->string('ref_model_id', 36)->nullable();
$table->timestamps();
$table->index(['ref_class']);
$table->index(['ref_model']);
});
Schema::create('user_awards', function (Blueprint $table) {

View File

@ -21,12 +21,12 @@ class CreateExpensesTable extends Migration
# ref fields are expenses tied to some model object
# EG, the airports has an internal expense for gate costs
$table->string('ref_class')->nullable();
$table->string('ref_class_id', 36)->nullable();
$table->string('ref_model')->nullable();
$table->string('ref_model_id', 36)->nullable();
$table->timestamps();
$table->index(['ref_class', 'ref_class_id']);
$table->index(['ref_model', 'ref_model_id']);
});
}

View File

@ -22,15 +22,15 @@ class CreateJournalTransactionsTable extends Migration
$table->char('currency', 5);
$table->text('memo')->nullable();
$table->string('tags')->nullable();
$table->string('ref_class', 50)->nullable();
$table->string('ref_class_id', 36)->nullable();
$table->string('ref_model', 50)->nullable();
$table->string('ref_model_id', 36)->nullable();
$table->timestamps();
$table->date('post_date');
$table->primary('id');
$table->index('journal_id');
$table->index('transaction_group');
$table->index(['ref_class', 'ref_class_id']);
$table->index(['ref_model', 'ref_model_id']);
});
}

View File

@ -98,8 +98,8 @@ awards:
name: Pilot 50 flights
description: When a pilot has 50 flights, give this award
image_url:
ref_class: App\Awards\PilotFlightAwards
ref_class_params: 50
ref_model: App\Awards\PilotFlightAwards
ref_model_params: 50
created_at: now
updated_at: now
@ -194,52 +194,52 @@ expenses:
amount: 100
type: 0
active: 1
ref_class: App\Models\Expense
ref_model: App\Models\Expense
- name: Per-Flight (multiplier)
amount: 100
type: 0
multiplier: 1
active: 1
ref_class: App\Models\Expense
ref_model: App\Models\Expense
- name: Per-Flight (multiplier, on airline)
airline_id: 1
amount: 200
type: 0
multiplier: 1
active: 1
ref_class: App\Models\Expense
ref_model: App\Models\Expense
- name: A daily fee
amount: 800
type: 1
active: 1
ref_class: App\Models\Expense
ref_model: App\Models\Expense
- name: A monthly fee
amount: 5000
type: 2
active: 1
ref_class: App\Models\Expense
ref_model: App\Models\Expense
- name: Catering
amount: 1000
type: 0
active: 1
ref_class: App\Models\Subfleet
ref_class_id: 1
ref_model: App\Models\Subfleet
ref_model_id: 1
created_at: now
updated_at: now
- name: Catering Staff
amount: 1000
type: 1
active: 1
ref_class: App\Models\Subfleet
ref_class_id: 1
ref_model: App\Models\Subfleet
ref_model_id: 1
created_at: now
updated_at: now
- name: Maintenance
amount: 1000
type: 1
active: 1
ref_class: App\Models\Aircraft
ref_class_id: 1
ref_model: App\Models\Aircraft
ref_model_id: 1
created_at: now
updated_at: now
@ -519,8 +519,8 @@ journal_transactions:
currency: USD
memo: 'Pilot Payment @ 50'
tags: '"pilot_pay"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15'
@ -533,8 +533,8 @@ journal_transactions:
currency: USD
memo: 'Expense: Per-Flight (no muliplier)'
tags: '"expense"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15'
@ -547,8 +547,8 @@ journal_transactions:
currency: USD
memo: 'Fares Y300; price: 200, cost: 0'
tags: '"fare"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15'
@ -561,8 +561,8 @@ journal_transactions:
currency: USD
memo: 'Expense: Per-Flight (multiplier, on airline)'
tags: '"expense"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15'
@ -575,8 +575,8 @@ journal_transactions:
currency: USD
memo: 'Expense: Per-Flight (multiplier)'
tags: '"expense"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15'
@ -589,8 +589,8 @@ journal_transactions:
currency: USD
memo: 'Subfleet Expense: Catering (747-43X RB211-524G)'
tags: '"subfleet"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15'
@ -603,8 +603,8 @@ journal_transactions:
currency: USD
memo: 'Fares F10; price: 1000, cost: 0'
tags: '"fare"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15'
@ -617,8 +617,8 @@ journal_transactions:
currency: USD
memo: 'Pilot Payment @ 50'
tags: '"pilot_pay"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: now
updated_at: now
post_date: now
@ -631,8 +631,8 @@ journal_transactions:
currency: USD
memo: 'Fares B10; price: 1100, cost: 0'
tags: '"fare"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: now
updated_at: now
post_date: now
@ -645,8 +645,8 @@ journal_transactions:
currency: USD
memo: 'Ground Handling'
tags: '"ground_handling"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: now
updated_at: now
post_date: now
@ -660,8 +660,8 @@ journal_transactions:
currency: USD
memo: 'Subfleet 744-3X-RB211: Block Time Cost'
tags: '"subfleet"'
ref_class: App\Models\Pirep
ref_class_id: pirepid_1
ref_model: App\Models\Pirep
ref_model_id: pirepid_1
created_at: now
updated_at: now
post_date: now

View File

@ -247,8 +247,8 @@ class AircraftController extends Controller
if ($request->isMethod('post')) {
$expense = new Expense($request->post());
$expense->ref_class = Aircraft::class;
$expense->ref_class_id = $aircraft->id;
$expense->ref_model = Aircraft::class;
$expense->ref_model_id = $aircraft->id;
$expense->save();
} elseif ($request->isMethod('put')) {
$expense = Expense::findOrFail($request->input('expense_id'));

View File

@ -255,8 +255,8 @@ class AirportController extends Controller
if ($request->isMethod('post')) {
$expense = new Expense($request->post());
$expense->ref_class = Airport::class;
$expense->ref_class_id = $airport->id;
$expense->ref_model = Airport::class;
$expense->ref_model_id = $airport->id;
$expense->save();
} elseif ($request->isMethod('put')) {
$expense = Expense::findOrFail($request->input('expense_id'));

View File

@ -53,7 +53,7 @@ class ExpenseController extends Controller
{
$this->expenseRepo->pushCriteria(new RequestCriteria($request));
$expenses = $this->expenseRepo->findWhere([
'ref_class' => Expense::class
'ref_model' => Expense::class
]);
return view('admin.expenses.index', [
@ -81,7 +81,7 @@ class ExpenseController extends Controller
public function store(Request $request)
{
$input = $request->all();
$input['ref_class'] = Expense::class;
$input['ref_model'] = Expense::class;
$this->expenseRepo->create($input);
Flash::success('Expense saved successfully.');

View File

@ -395,8 +395,8 @@ class SubfleetController extends Controller
*/
if ($request->isMethod('post')) {
$expense = new Expense($request->post());
$expense->ref_class = Subfleet::class;
$expense->ref_class_id = $subfleet->id;
$expense->ref_model = Subfleet::class;
$expense->ref_model_id = $subfleet->id;
$expense->save();
} elseif ($request->isMethod('put')) {
$expense = Expense::findOrFail($request->input('expense_id'));

View File

@ -56,9 +56,9 @@ abstract class Award
final public function handle(): void
{
# Check if the params are a JSON object or array
$param = $this->award->ref_class_params;
if (Utils::isObject($this->award->ref_class_params)) {
$param = json_decode($this->award->ref_class_params);
$param = $this->award->ref_model_params;
if (Utils::isObject($this->award->ref_model_params)) {
$param = json_decode($this->award->ref_model_params);
}
if ($this->check($param)) {

View File

@ -7,8 +7,8 @@ use App\Interfaces\Model;
/**
* The Award model
* @property mixed id
* @property mixed ref_class
* @property mixed|null ref_class_params
* @property mixed ref_model
* @property mixed|null ref_model_params
* @package Award\Models
*/
class Award extends Model
@ -19,16 +19,16 @@ class Award extends Model
'name',
'description',
'image_url',
'ref_class',
'ref_class_params',
'ref_model',
'ref_model_params',
];
public static $rules = [
'name' => 'required',
'description' => 'nullable',
'image_url' => 'nullable',
'ref_class' => 'required',
'ref_class_params' => 'nullable'
'ref_model' => 'required',
'ref_model_params' => 'nullable'
];
/**
@ -39,12 +39,12 @@ class Award extends Model
*/
public function getReference(Award $award = null, User $user = null)
{
if (!$this->ref_class) {
if (!$this->ref_model) {
return null;
}
try {
return new $this->ref_class($award, $user);
return new $this->ref_model($award, $user);
} catch (\Exception $e) {
return null;
}

View File

@ -8,8 +8,8 @@ use App\Interfaces\Model;
* @property int airline_id
* @property float amount
* @property string name
* @property string ref_class
* @property string ref_class_id
* @property string ref_model
* @property string ref_model_id
* @package App\Models
*/
class Expense extends Model
@ -23,8 +23,8 @@ class Expense extends Model
'type',
'multiplier',
'charge_to_user',
'ref_class',
'ref_class_id',
'ref_model',
'ref_model_id',
'active',
];
@ -42,18 +42,18 @@ class Expense extends Model
*/
public function getReference()
{
if (!$this->ref_class || !$this->ref_class_id) {
if (!$this->ref_model || !$this->ref_model_id) {
return null;
}
if ($this->ref_class === __CLASS__) {
if ($this->ref_model === __CLASS__) {
return $this;
}
try {
$klass = new $this->ref_class;
$klass = new $this->ref_model;
return $klass->find($this->ref_class_id);
return $klass->find($this->ref_model_id);
} catch (\Exception $e) {
return null;
}

View File

@ -130,8 +130,8 @@ class Journal extends Model
{
return $this
->transactions()
->where('ref_class', \get_class($object))
->where('ref_class_id', $object->id);
->where('ref_model', \get_class($object))
->where('ref_model_id', $object->id);
}
/**

View File

@ -16,8 +16,8 @@ use App\Interfaces\Model;
* @property string post_date
* @property integer credit
* @property integer debit
* @property string ref_class
* @property integer ref_class_id
* @property string ref_model
* @property integer ref_model_id
* @property Journal journal
*/
class JournalTransaction extends Model
@ -34,8 +34,8 @@ class JournalTransaction extends Model
'currency',
'memo',
'tags',
'ref_class',
'ref_class_id',
'ref_model',
'ref_model_id',
'post_date'
];
@ -67,8 +67,8 @@ class JournalTransaction extends Model
*/
public function referencesObject($object)
{
$this->ref_class = \get_class($object);
$this->ref_class_id = $object->id;
$this->ref_model = \get_class($object);
$this->ref_model_id = $object->id;
$this->save();
return $this;
@ -79,10 +79,10 @@ class JournalTransaction extends Model
*/
public function getReferencedObject()
{
if ($classname = $this->ref_class) {
$klass = new $this->ref_class;
if ($classname = $this->ref_model) {
$klass = new $this->ref_model;
return $klass->find($this->ref_class_id);
return $klass->find($this->ref_model_id);
}
return false;

View File

@ -375,8 +375,8 @@ class Pirep extends Model
public function transactions()
{
return $this->hasMany(JournalTransaction::class, 'ref_class_id')
->where('ref_class', __CLASS__)
return $this->hasMany(JournalTransaction::class, 'ref_model_id')
->where('ref_model', __CLASS__)
->orderBy('credit', 'desc')
->orderBy('debit', 'desc');
}

View File

@ -19,8 +19,8 @@ trait ExpensableTrait
return $this->morphMany(
Expense::class,
'expenses', # overridden by the next two anyway
'ref_class',
'ref_class_id'
'ref_model',
'ref_model_id'
);
}
}

View File

@ -26,18 +26,18 @@ class ExpenseRepository extends Repository implements CacheableInterface
* include expenses for a given airline ID
* @param $type
* @param null $airline_id
* @param null $ref_class
* @param null $ref_model
* @return Collection
*/
public function getAllForType($type, $airline_id = null, $ref_class = null)
public function getAllForType($type, $airline_id = null, $ref_model = null)
{
$where = [
'type' => $type,
['airline_id', '=', null]
];
if ($ref_class) {
$where['ref_class'] = $ref_class;
if ($ref_model) {
$where['ref_model'] = $ref_model;
}
$expenses = $this->findWhere($where);
@ -48,8 +48,8 @@ class ExpenseRepository extends Repository implements CacheableInterface
'airline_id' => $airline_id
];
if ($ref_class) {
$where['ref_class'] = $ref_class;
if ($ref_model) {
$where['ref_model'] = $ref_model;
}
$airline_expenses = $this->findWhere($where);

View File

@ -113,8 +113,8 @@ class JournalRepository extends Repository implements CacheableInterface
];
if ($reference !== null) {
$attrs['ref_class'] = \get_class($reference);
$attrs['ref_class_id'] = $reference->id;
$attrs['ref_model'] = \get_class($reference);
$attrs['ref_model_id'] = $reference->id;
}
try {
@ -238,8 +238,8 @@ class JournalRepository extends Repository implements CacheableInterface
public function getAllForObject($object, $journal = null, Carbon $date = null)
{
$where = [
'ref_class' => \get_class($object),
'ref_class_id' => $object->id,
'ref_model' => \get_class($object),
'ref_model_id' => $object->id,
];
if ($journal) {
@ -272,8 +272,8 @@ class JournalRepository extends Repository implements CacheableInterface
public function deleteAllForObject($object, $journal = null)
{
$where = [
'ref_class' => \get_class($object),
'ref_class_id' => $object->id,
'ref_model' => \get_class($object),
'ref_model_id' => $object->id,
];
if ($journal) {

View File

@ -200,19 +200,19 @@ class PirepFinanceService extends Service
Log::info('Finance: PIREP: '.$pirep->id.', expense:', $expense->toArray());
# Get the transaction group name from the ref_class name
# Get the transaction group name from the ref_model name
# This way it can be more dynamic and don't have to add special
# tables or specific expense calls to accomodate all of these
$klass = 'Expense';
if ($expense->ref_class) {
$ref = explode('\\', $expense->ref_class);
if ($expense->ref_model) {
$ref = explode('\\', $expense->ref_model);
$klass = end($ref);
}
# Form the memo, with some specific ones depending on the group
if ($klass === 'Airport') {
$memo = "Airport Expense: {$expense->name} ({$expense->ref_class_id})";
$transaction_group = "Airport: {$expense->ref_class_id}";
$memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})";
$transaction_group = "Airport: {$expense->ref_model_id}";
} elseif ($klass === 'Subfleet') {
$memo = "Subfleet Expense: {$expense->name} ({$pirep->aircraft->subfleet->name})";
$transaction_group = "Subfleet: {$expense->name} ({$pirep->aircraft->subfleet->name})";

View File

@ -57,15 +57,15 @@ class RecurringFinanceService extends Service
protected function getMemoAndGroup(Expense $expense): array
{
$klass = 'Expense';
if ($expense->ref_class) {
$ref = explode('\\', $expense->ref_class);
if ($expense->ref_model) {
$ref = explode('\\', $expense->ref_model);
$klass = end($ref);
$obj = $expense->getReference();
}
if ($klass === 'Airport') {
$memo = "Airport Expense: {$expense->name} ({$expense->ref_class_id})";
$transaction_group = "Airport: {$expense->ref_class_id}";
$memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})";
$transaction_group = "Airport: {$expense->ref_model_id}";
} elseif ($klass === 'Subfleet') {
$memo = "Subfleet Expense: {$expense->name}";
$transaction_group = "Subfleet: {$expense->name}";
@ -111,8 +111,8 @@ class RecurringFinanceService extends Service
# against this specific journal, on today
$w = [
'journal_id' => $journal->id,
'ref_class' => Expense::class,
'ref_class_id' => $expense->id,
'ref_model' => Expense::class,
'ref_model_id' => $expense->id,
];
$found = JournalTransaction::where($w)

View File

@ -48,26 +48,26 @@ class ExpenseExporter extends ImportExport
// For the different expense types, instead of exporting
// the ID, export a specific column
if ($expense->ref_class === Expense::class) {
$ret['ref_class'] = '';
$ret['ref_class_id'] = '';
if ($expense->ref_model === Expense::class) {
$ret['ref_model'] = '';
$ret['ref_model_id'] = '';
} else {
$obj = $expense->getReference();
if(!$obj) { // bail out
return $ret;
}
if ($expense->ref_class === Aircraft::class) {
$ret['ref_class_id'] = $obj->registration;
} elseif ($expense->ref_class === Airport::class) {
$ret['ref_class_id'] = $obj->icao;
} elseif ($expense->ref_class === Subfleet::class) {
$ret['ref_class_id'] = $obj->type;
if ($expense->ref_model === Aircraft::class) {
$ret['ref_model_id'] = $obj->registration;
} elseif ($expense->ref_model === Airport::class) {
$ret['ref_model_id'] = $obj->icao;
} elseif ($expense->ref_model === Subfleet::class) {
$ret['ref_model_id'] = $obj->type;
}
}
// And convert the ref_class into the shorter name
$ret['ref_class'] = str_replace('App\Models\\', '', $ret['ref_class']);
// And convert the ref_model into the shorter name
$ret['ref_model'] = str_replace('App\Models\\', '', $ret['ref_model']);
return $ret;
}

View File

@ -30,8 +30,8 @@ class ExpenseImporter extends ImportExport
'charge_to_user' => 'nullable|boolean',
'multiplier' => 'nullable|numeric',
'active' => 'nullable|boolean',
'ref_class' => 'nullable',
'ref_class_id' => 'nullable',
'ref_model' => 'nullable',
'ref_model_id' => 'nullable',
];
/**
@ -70,27 +70,27 @@ class ExpenseImporter extends ImportExport
}
/**
* See if this expense refers to a ref_class
* See if this expense refers to a ref_model
* @param array $row
* @return array
*/
protected function getRefClassInfo(array $row)
{
$row['ref_class'] = trim($row['ref_class']);
$row['ref_model'] = trim($row['ref_model']);
// class from import is being saved as the name of the model only
// prepend the full class path so we can search it out
if (\strlen($row['ref_class']) > 0) {
if (substr_count($row['ref_class'], 'App\Models\\') === 0) {
$row['ref_class'] = 'App\Models\\'.$row['ref_class'];
if (\strlen($row['ref_model']) > 0) {
if (substr_count($row['ref_model'], 'App\Models\\') === 0) {
$row['ref_model'] = 'App\Models\\'.$row['ref_model'];
}
} else {
$row['ref_class'] = Expense::class;
$row['ref_model'] = Expense::class;
return $row;
}
$class = $row['ref_class'];
$id = $row['ref_class_id'];
$class = $row['ref_model'];
$id = $row['ref_model_id'];
$obj = null;
if ($class === Aircraft::class) {
@ -110,7 +110,7 @@ class ExpenseImporter extends ImportExport
return $row;
}
$row['ref_class_id'] = $obj->id;
$row['ref_model_id'] = $obj->id;
return $row;
}
}

112
composer.lock generated
View File

@ -168,7 +168,7 @@
"Arrilot\\Widgets\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -223,7 +223,7 @@
"Cache\\Adapter\\Common\\": ""
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -291,7 +291,7 @@
"/Tests/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -353,7 +353,7 @@
"/Tests/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -408,7 +408,7 @@
"Cache\\TagInterop\\": ""
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -527,7 +527,7 @@
"Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -643,7 +643,7 @@
"Cron\\": "src/Cron/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -703,7 +703,7 @@
"Egulias\\EmailValidator\\": "EmailValidator"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -868,7 +868,7 @@
"src/functions_include.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -923,7 +923,7 @@
"src/functions_include.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -985,7 +985,7 @@
"Hashids\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1120,7 +1120,7 @@
"Irazasyed\\LaravelGAMP\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1167,7 +1167,7 @@
"Jackiedo\\Timezonelist\\": "src/Jackiedo/Timezonelist"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1220,7 +1220,7 @@
"stubs/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1271,7 +1271,7 @@
"Joshbrw\\LaravelModuleInstaller\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1304,7 +1304,7 @@
"Traitor\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1363,7 +1363,7 @@
"src/Laracasts/Flash/functions.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -1378,16 +1378,16 @@
},
{
"name": "laravel/framework",
"version": "v5.6.14",
"version": "v5.6.15",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "fba33e59fd43661933e9cecb84dfb0a64c5323ce"
"reference": "baa42cf6bdd942523fafece21ec16a1843c6db0f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/fba33e59fd43661933e9cecb84dfb0a64c5323ce",
"reference": "fba33e59fd43661933e9cecb84dfb0a64c5323ce",
"url": "https://api.github.com/repos/laravel/framework/zipball/baa42cf6bdd942523fafece21ec16a1843c6db0f",
"reference": "baa42cf6bdd942523fafece21ec16a1843c6db0f",
"shasum": ""
},
"require": {
@ -1512,7 +1512,7 @@
"framework",
"laravel"
],
"time": "2018-03-28T14:17:03+00:00"
"time": "2018-03-30T13:29:58+00:00"
},
{
"name": "laravelcollective/html",
@ -1839,7 +1839,7 @@
"League\\ISO3166\\": "src"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2032,7 +2032,7 @@
"VaCentral\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2189,7 +2189,7 @@
"src/helpers.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2298,7 +2298,7 @@
"Http\\Discovery\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2351,7 +2351,7 @@
"PhpUnitsOfMeasure\\": "source/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2474,7 +2474,7 @@
"PragmaRX\\Yaml\\Tests\\": "tests/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2535,7 +2535,7 @@
"Prettus\\Repository\\": "src/Prettus/Repository/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2624,7 +2624,7 @@
"Psr\\Cache\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2888,7 +2888,7 @@
"Ramsey\\Uuid\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -3171,7 +3171,7 @@
"Spatie\\Pjax\\": "src"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -3822,7 +3822,7 @@
"bootstrap.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -3878,7 +3878,7 @@
"bootstrap.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -4397,7 +4397,7 @@
"TheIconic\\Tracking\\GoogleAnalytics\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -4442,7 +4442,7 @@
"TijsVerkoyen\\CssToInlineStyles\\": "src"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -4483,7 +4483,7 @@
"Tivie\\OS\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"APACHE 2.0"
],
@ -4601,7 +4601,7 @@
"src/vierbergenlars/SemVer/internal.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -4706,7 +4706,7 @@
"Webpatser\\Uuid": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -4762,7 +4762,7 @@
"/Tests/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -4833,7 +4833,7 @@
"Barryvdh\\LaravelIdeHelper\\": "src"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -5041,7 +5041,7 @@
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -5098,7 +5098,7 @@
"Whoops\\": "src/Whoops/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -5303,7 +5303,7 @@
"JakubOnderka\\PhpConsoleColor": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
@ -5347,7 +5347,7 @@
"JakubOnderka\\PhpConsoleHighlighter": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -5456,7 +5456,7 @@
"src/DeepCopy/deep_copy.php"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -5726,7 +5726,7 @@
]
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -5822,7 +5822,7 @@
"Prophecy\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -5892,7 +5892,7 @@
"src/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -5940,7 +5940,7 @@
"src/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -6031,7 +6031,7 @@
"src/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -6081,7 +6081,7 @@
"src/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -6215,7 +6215,7 @@
"src/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -6312,7 +6312,7 @@
"src/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -6375,7 +6375,7 @@
"src/"
]
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@ -6925,7 +6925,7 @@
"Webmozart\\Assert\\": "src/"
}
},
"notification-url": "http://packagist.org/downloads/",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],

View File

@ -46,20 +46,20 @@
<div class="form-group col-sm-6">
<div>
{{ Form::label('ref_class', 'Award Class:') }}
{{ Form::select('ref_class', $award_classes, null , [
{{ Form::label('ref_model', 'Award Class:') }}
{{ Form::select('ref_model', $award_classes, null , [
'class' => 'form-control select2',
'id' => 'award_class_select',
]) }}
<p class="text-danger">{{ $errors->first('ref_class') }}</p>
<p class="text-danger">{{ $errors->first('ref_model') }}</p>
</div>
<div>
{{ Form::label('ref_class_params', 'Award Class parameters') }}
{{ Form::text('ref_class_params', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('ref_class_params') }}</p>
{{ Form::label('ref_model_params', 'Award Class parameters') }}
{{ Form::text('ref_model_params', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('ref_model_params') }}</p>
<p id="ref_class_param_description">
<p id="ref_model_param_description">
</p>
</div>

View File

@ -9,7 +9,7 @@
const changeParamDescription = (award_class) => {
const descrip = award_descriptions[award_class];
console.log('Found description: ', descrip);
$("p#ref_class_param_description").text(descrip);
$("p#ref_model_param_description").text(descrip);
};
$(document).ready(() => {

View File

@ -30,8 +30,8 @@ class AwardsTest extends TestCase
{
// Create one award that's given out with one flight
$award = factory(App\Models\Award::class)->create([
'ref_class' => App\Awards\PilotFlightAwards::class,
'ref_class_params' => 1,
'ref_model' => App\Awards\PilotFlightAwards::class,
'ref_model_params' => 1,
]);
$user = factory(App\Models\User::class)->create([

View File

@ -101,8 +101,8 @@ class FinanceTest extends TestCase
# Add a subfleet expense
factory(App\Models\Expense::class)->create([
'ref_class' => \App\Models\Subfleet::class,
'ref_class_id' => $subfleet['subfleet']->id,
'ref_model' => \App\Models\Subfleet::class,
'ref_model_id' => $subfleet['subfleet']->id,
'amount' => 200
]);
@ -605,7 +605,7 @@ class FinanceTest extends TestCase
factory(App\Models\Expense::class)->create([
'airline_id' => null,
'ref_class' => \App\Models\Subfleet::class,
'ref_model' => \App\Models\Subfleet::class,
]);
$expenses = $this->expenseRepo->getAllForType(

View File

@ -386,12 +386,12 @@ class ImporterTest extends TestCase
$catering = $expenses->where('name', 'Catering Staff')->first();
$this->assertEquals(1000, $catering->amount);
$this->assertEquals(\App\Models\Enums\ExpenseType::DAILY, $catering->type);
$this->assertEquals(\App\Models\Subfleet::class, $catering->ref_class);
$this->assertEquals($subfleet->id, $catering->ref_class_id);
$this->assertEquals(\App\Models\Subfleet::class, $catering->ref_model);
$this->assertEquals($subfleet->id, $catering->ref_model_id);
$mnt = $expenses->where('name', 'Maintenance')->first();
$this->assertEquals(\App\Models\Aircraft::class, $mnt->ref_class);
$this->assertEquals($aircraft->id, $mnt->ref_class_id);
$this->assertEquals(\App\Models\Aircraft::class, $mnt->ref_model);
$this->assertEquals($aircraft->id, $mnt->ref_model_id);
}
/**

View File

@ -1,4 +1,4 @@
airline,name,amount,type,charge_to_user,multiplier,active,ref_class,ref_class_id
airline,name,amount,type,charge_to_user,multiplier,active,ref_model,ref_model_id
,"Per-Flight (no muliplier)",100,F,0,0,1,,
,"Per-Flight (multiplier)",100,F,0,1,1,,
VMS,"Per-Flight (multiplier, on airline)",200,F,0,1,1,,

1 airline name amount type charge_to_user multiplier active ref_class ref_model ref_class_id ref_model_id
2 Per-Flight (no muliplier) 100 F 0 0 1
3 Per-Flight (multiplier) 100 F 0 1 1
4 VMS Per-Flight (multiplier, on airline) 200 F 0 1 1

View File

@ -1,4 +1,4 @@
airline,name,amount,type,charge_to_user,multiplier,active,ref_class,ref_class_id
airline,name,amount,type,charge_to_user,multiplier,active,ref_model,ref_model_id
,"Per-Flight (no muliplier)",100,F,0,0,1,,
,"Per-Flight (multiplier)",100,F,0,1,1,,
VMS,"Per-Flight (multiplier, on airline)",200,F,0,1,1,,

1 airline name amount type charge_to_user multiplier active ref_class ref_model ref_class_id ref_model_id
2 Per-Flight (no muliplier) 100 F 0 0 1
3 Per-Flight (multiplier) 100 F 0 1 1
4 VMS Per-Flight (multiplier, on airline) 200 F 0 1 1