Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/CsvSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class CsvSeeder extends Seeder
* created_at and updated_at values to be added to each row. Only used if
* $this->timestamps is true
*/
public string $created_at = '';
public string $updated_at = '';
public ?Carbon $created_at = null;
public ?Carbon $updated_at = null;

/**
* The mapping of CSV to DB column. If not specified manually, the first
Expand All @@ -98,10 +98,10 @@ public function run()
// Cache created_at and updated_at if we need to
if ($this->timestamps) {
if (!$this->created_at) {
$this->created_at = Carbon::now()->toIso8601String();
$this->created_at = Carbon::now();
}
if (!$this->updated_at) {
$this->updated_at = Carbon::now()->toIso8601String();
$this->updated_at = Carbon::now();
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function it_adds_timestamps()

// Test with timestamps
$seeder->timestamps = true;
$seeder->created_at = \Carbon\Carbon::now()->toString();
$seeder->created_at = \Carbon\Carbon::now();
$seeder->updated_at = $seeder->created_at;
$actual = $seeder->readRow($row, $mapping);
$expected = [
Expand Down