fix aircraft status field type in model

This commit is contained in:
Nabeel Shahzad
2018-03-30 21:45:11 -05:00
parent a3bfcf01b7
commit 9eb8ed1804
4 changed files with 10 additions and 4 deletions

View File

@@ -44,7 +44,6 @@ class Aircraft extends Model
protected $casts = [
'subfleet_id' => 'integer',
'zfw' => 'float',
'status' => 'integer',
'state' => 'integer',
];

View File

@@ -108,7 +108,12 @@ class ImportService extends Service
// turn it into a collection and run some filtering
$row = collect($row)->map(function ($val, $index) {
return trim($val);
$val = trim($val);
if($val === '') {
return null;
}
return $val;
})->toArray();
# Try to validate

View File

@@ -555,6 +555,8 @@ class ImporterTest extends TestCase
$this->assertEquals($subfleet->id, $aircraft->id);
$this->assertEquals('A320-211', $aircraft->name);
$this->assertEquals('N309US', $aircraft->registration);
$this->assertEquals('A', $aircraft->status);
$this->assertEquals(null, $aircraft->zfw);
}
/**

View File

@@ -1,3 +1,3 @@
subfleet,iata, icao, name,registration,hex_code,status
A32X,A320,320,A320-211,N309US,,
subfleet,iata, icao, name,registration,hex_code,zfw,status
A32X,A320,320,A320-211,N309US,,,A
74X,747 400, ,,
1 subfleet,iata, icao, name,registration,hex_code,status subfleet,iata, icao, name,registration,hex_code,zfw,status
2 A32X,A320,320,A320-211,N309US,, A32X,A320,320,A320-211,N309US,,,A
3 74X,747 400, ,, 74X,747 400, ,,