#32 subfleet classificiation scaffolding

This commit is contained in:
Nabeel Shahzad
2017-06-22 20:55:45 -05:00
parent 6bbb37061b
commit aaaead77a5
28 changed files with 493 additions and 348 deletions

View File

@@ -52,22 +52,19 @@ class Aircraft extends Model
];
/**
* foreign key
* foreign keys
*/
public function class()
{
return $this->belongsTo(
'App\Models\AircraftClass',
'aircraft_class_id'
);
}
public function fares()
{
$r = $this->belongsToMany(
return $this->belongsToMany(
'App\Models\Fare',
'aircraft_fare'
)->withPivot('price', 'cost', 'capacity');
return $r;
}
public function subfleet()
{
return $this->belongsTo('App\Models\Subfleet', 'subfleet_id');
}
}

View File

@@ -1,45 +0,0 @@
<?php
namespace App\Models;
use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class AircraftClass
* @package App\Models
* @version June 9, 2017, 8:10 pm UTC
*/
class AircraftClass extends Model
{
public $table = 'aircraft_classes';
protected $dates = ['deleted_at'];
public $fillable = [
'code',
'name',
'notes'
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'code' => 'string',
'name' => 'string',
'notes' => 'string'
];
/**
* Validation rules
*
* @var array
*/
public static $rules = [
'code' => 'required',
'name' => 'required'
];
}

View File

@@ -8,7 +8,6 @@ use Eloquent as Model;
* Class Fare
*
* @package App\Models
* @version June 10, 2017, 4:03 am UTC
*/
class Fare extends Model
{
@@ -52,6 +51,10 @@ class Fare extends Model
'name' => 'required',
];
/**
* any foreign keys
*/
public function aircraft() {
return $this->belongsToMany(
'App\Models\Aircraft',

View File

@@ -42,4 +42,11 @@ class Rank extends Model
public static $rules = [
'name' => 'unique',
];
public function subfleets() {
return $this->belongsToMany(
'App\Models\Subfleet',
'subfleet_rank'
)->withPivot('acars_pay', 'manual_pay');
}
}

60
app/Models/Subfleet.php Normal file
View File

@@ -0,0 +1,60 @@
<?php
namespace App\Models;
use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Subfleet
* @package App\Models
*/
class Subfleet extends Model
{
use SoftDeletes;
public $table = 'subfleets';
protected $dates = ['deleted_at'];
public $fillable = [
'airline_id',
'name',
'type'
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'airline_id' => 'integer',
'name' => 'string',
'type' => 'string'
];
/**
* Validation rules
*
* @var array
*/
public static $rules = [
];
public function airline()
{
return $this->belongsTo('App\Models\Airline', 'airline_id');
}
public function ranks()
{
return $this->belongsToMany(
'App\Models\Ranks',
'subfleet_rank'
)->withPivot('acars_pay', 'manual_pay');
}
}