@@ -17,7 +17,7 @@ class ImportIndustrialParkCandidates extends Command
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$document = json_decode(file_get_contents(database_path('data/industrial-park-candidate-drafts.json')), true, flags: JSON_THROW_ON_ERROR);
|
||||
$document = json_decode($this->readSource(database_path('data/industrial-park-candidate-drafts.json')), true, flags: JSON_THROW_ON_ERROR);
|
||||
if (($document['source_document_attached'] ?? null) !== true
|
||||
|| ($document['source_document_reconciled'] ?? null) !== true) {
|
||||
$this->error('The source document must be attached and reconciled before importing drafts. No records written.');
|
||||
@@ -106,4 +106,14 @@ class ImportIndustrialParkCandidates extends Command
|
||||
{
|
||||
return Str::upper(Str::ascii(trim($value)));
|
||||
}
|
||||
|
||||
private function readSource(string $path): string
|
||||
{
|
||||
$bytes = file_get_contents($path);
|
||||
if ($bytes === false) {
|
||||
throw new RuntimeException('Source file is unavailable: '.$path);
|
||||
}
|
||||
|
||||
return $bytes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user