Rename 'Airlines' model to 'Airline'
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
$factory->define(App\Models\AircraftClass::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'id' => 1,
|
||||
'code' => 'H',
|
||||
'name' => 'Heavy',
|
||||
'notes' => 'Heavy aircraft',
|
||||
];
|
||||
});
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
$factory->define(App\Models\Fare::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'code' => 'Y',
|
||||
'name' => 'Economy',
|
||||
'price' => '100',
|
||||
'capacity' => '200',
|
||||
];
|
||||
});
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
$factory->define(App\Models\Flight::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'code' => 'Y',
|
||||
'name' => 'Economy',
|
||||
'price' => '100',
|
||||
'capacity' => '200',
|
||||
];
|
||||
});
|
||||
@@ -12,7 +12,35 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->seed_from_yaml(App::environment());
|
||||
}
|
||||
|
||||
protected function seed_from_yaml($env): void
|
||||
{
|
||||
$path = database_path('seeds/'.$env.'.yml');
|
||||
|
||||
$time_fields = ['created_at', 'updated_at'];
|
||||
$curr_time = Carbon::now('UTC')->format('Y-m-d H:i:s');
|
||||
|
||||
$yml = Yaml::parse(file_get_contents($path));
|
||||
foreach ($yml as $table => $rows) {
|
||||
foreach ($rows as $row) {
|
||||
|
||||
# encrypt any password fields
|
||||
if (array_key_exists('password', $row)) {
|
||||
$row['password'] = bcrypt($row['password']);
|
||||
}
|
||||
|
||||
# if any time fields are == to "now", then insert the right time
|
||||
foreach ($time_fields as $tf) {
|
||||
if (array_key_exists($tf, $row) && $row[$tf] === 'now') {
|
||||
$row[$tf] = $curr_time;
|
||||
}
|
||||
}
|
||||
|
||||
DB::table($table)->insert($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user