Merge branch 'dev' of https://github.com/nabeelio/phpvms into dev
This commit is contained in:
@@ -3,10 +3,8 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Interfaces\Service;
|
||||
use App\Support\Database;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Webpatser\Uuid\Uuid;
|
||||
|
||||
/**
|
||||
@@ -42,8 +40,7 @@ class DatabaseService extends Service
|
||||
*/
|
||||
public function seed_from_yaml_file($yaml_file, $ignore_errors = false): array
|
||||
{
|
||||
$yml = file_get_contents($yaml_file);
|
||||
return $this->seed_from_yaml($yml, $ignore_errors);
|
||||
return Database::seed_from_yaml_file($yaml_file, $ignore_errors);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,27 +51,7 @@ class DatabaseService extends Service
|
||||
*/
|
||||
public function seed_from_yaml($yml, $ignore_errors = false): array
|
||||
{
|
||||
$imported = [];
|
||||
$yml = Yaml::parse($yml);
|
||||
foreach ($yml as $table => $rows) {
|
||||
$imported[$table] = 0;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
try {
|
||||
$row = $this->insert_row($table, $row);
|
||||
} catch(QueryException $e) {
|
||||
if ($ignore_errors) {
|
||||
continue;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
++$imported[$table];
|
||||
}
|
||||
}
|
||||
|
||||
return $imported;
|
||||
return Database::seed_from_yaml($yml, $ignore_errors);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,24 +69,6 @@ class DatabaseService extends Service
|
||||
}
|
||||
}
|
||||
|
||||
# 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($row as $column => $value) {
|
||||
if(strtolower($value) === 'now') {
|
||||
$row[$column] = $this->time();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
DB::table($table)->insert($row);
|
||||
} catch (QueryException $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $row;
|
||||
return Database::insert_row($table, $row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Models\Bid;
|
||||
use App\Models\Enums\AcarsType;
|
||||
use App\Models\Enums\PirepSource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Enums\PirepStatus;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\Navdata;
|
||||
use App\Models\Pirep;
|
||||
@@ -212,6 +213,10 @@ class PirepService extends Service
|
||||
}
|
||||
}
|
||||
|
||||
$pirep->state = $default_state;
|
||||
$pirep->status = PirepStatus::ARRIVED;
|
||||
$pirep->save();
|
||||
|
||||
Log::info('New PIREP filed', [$pirep]);
|
||||
event(new PirepFiled($pirep));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user