include vagrant and update README

This commit is contained in:
Nabeel Shahzad
2017-06-13 12:50:03 -05:00
parent 486b47562e
commit b4dac95d1b
9 changed files with 434 additions and 14 deletions

View File

@@ -0,0 +1,48 @@
<?php
use Carbon\Carbon;
use Illuminate\Database\Seeder;
class DevelopmentSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->seed_from_yaml();
}
protected function time(): string
{
return Carbon::now('UTC')->format('Y-m-d H:i:s');
}
protected function seed_from_yaml(): void
{
$time_fields = ['created_at', 'updated_at'];
$yml = Yaml::parse(file_get_contents(database_path('seeds/dev.yml')));
foreach ($yml as $table => $rows) {
foreach ($rows as $row) {
# encrypt any password fields
if(in_array('password', $row, true)) {
$row['password'] = bcrypt($row['password']);
}
# if any time fields are == to "now", then insert the right time
foreach($time_fields as $tf) {
if(in_array($tf, $row, true) && $row[$tf] === 'now') {
$row[$tf] = $this->time();
}
}
DB::table($table)->insert($row);
}
}
}
}

View File

@@ -1,11 +1,34 @@
#
roles:
- id: 1
name: admin
display_name: Administrators
- id: 2
name: user
display_name: Pilot
users:
- id: 1
name: Admin User
email: admin@phpvms.net
password: admin
created_at: now
updated_at: now
role_user:
- user_id: 1
role_id: 1
- user_id: 1
role_id: 2
airlines:
- id: 1
code: VMS
name: phpvms airlines
active: 1
created_at: now
updated_at: now
#
airports:
- icao: KAUS
name: Austin-Bergstrom International Airport