diff --git a/app/Models/Aircraft.php b/app/Models/Aircraft.php index 29c35893..2049dd9d 100644 --- a/app/Models/Aircraft.php +++ b/app/Models/Aircraft.php @@ -44,7 +44,6 @@ class Aircraft extends Model protected $casts = [ 'subfleet_id' => 'integer', 'zfw' => 'float', - 'status' => 'integer', 'state' => 'integer', ]; diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index ccd61e15..50b7c876 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -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 diff --git a/tests/ImporterTest.php b/tests/ImporterTest.php index 97f9dccb..a49da3ec 100644 --- a/tests/ImporterTest.php +++ b/tests/ImporterTest.php @@ -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); } /** diff --git a/tests/data/aircraft.csv b/tests/data/aircraft.csv index b1f0f1ac..69c68b75 100644 --- a/tests/data/aircraft.csv +++ b/tests/data/aircraft.csv @@ -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, ,,