Skip to content

Commit

Permalink
fixed null date column blew up array flip (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
romalytvynenko authored Aug 5, 2023
1 parent bc7811c commit f6422be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Support/ResponseExtractor/ModelInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ protected function getCastType($column, $model)
protected function getCastsWithDates($model)
{
return collect($model->getDates())
->filter()
->flip()
->map(fn () => 'datetime')
->merge($model->getCasts());
Expand Down
16 changes: 16 additions & 0 deletions tests/Support/ResponseExtractor/ModelInfoTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Dedoc\Scramble\Support\ResponseExtractor\ModelInfo;

it('handles model without updated_at column', function () {
$modelInfo = new ModelInfo(UserModelWithoutUpdatedAt::class);

$modelInfo->handle();
})->expectNotToPerformAssertions();

class UserModelWithoutUpdatedAt extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'users';

const UPDATED_AT = null;
}

0 comments on commit f6422be

Please sign in to comment.