diff --git a/app/Console/Commands/SablogImport.php b/app/Console/Commands/SablogImport.php index cd57e15..a49f1e5 100644 --- a/app/Console/Commands/SablogImport.php +++ b/app/Console/Commands/SablogImport.php @@ -224,7 +224,7 @@ class SablogImport extends Command 'regip' => $row['regip'] ?: null, 'logintime' => $row['logintime'] ? date('Y-m-d H:i:s', (int) $row['logintime']) : null, 'lastpost_at' => $row['lastpost'] ? date('Y-m-d H:i:s', (int) $row['lastpost']) : null, - 'created_at' => date('Y-m-d H:i:s', (int) $row['regdateline']), + 'created_at' => ($ts = (int) $row['regdateline']) > 0 ? date('Y-m-d H:i:s', $ts) : now(), 'updated_at' => now(), ]); @@ -252,7 +252,7 @@ class SablogImport extends Command foreach ($this->rows('articles') as $row) { $slug = SlugGenerator::make($row['title'], 'posts', 'slug', ignoreId: (int) $row['articleid'], fallback: 'post-'.$row['articleid']); $status = (int) $row['visible'] === 1 ? 'published' : 'draft'; - $dateline = date('Y-m-d H:i:s', (int) $row['dateline']); + $dateline = ($ts = (int) $row['dateline']) > 0 ? date('Y-m-d H:i:s', $ts) : now()->toDateTimeString(); DB::table('posts')->updateOrInsert(['id' => (int) $row['articleid']], [ 'category_id' => (int) $row['cid'] ?: null, @@ -325,7 +325,7 @@ class SablogImport extends Command 'content' => $row['content'], 'ip' => $row['ipaddress'] ?: null, 'status' => (int) $row['visible'] === 1 ? 'published' : 'pending', - 'created_at' => date('Y-m-d H:i:s', (int) $row['dateline']), + 'created_at' => ($ts = (int) $row['dateline']) > 0 ? date('Y-m-d H:i:s', $ts) : null, ]); $count++; }