Skip to content

Commit

Permalink
fill in created_at/updated_at for media
Browse files Browse the repository at this point in the history
  • Loading branch information
davidharting committed Dec 21, 2024
1 parent 00b67b4 commit d11fbd4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/Actions/SofaImport/SofaRowHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ private function handleMedia(): int

$isNew = $this->media->wasRecentlyCreated;

// created_at and updated_at were not fillable before I ran this the first time.
// So update that so that media timestamps reflect when I added them to lists rather than current time
if (! $isNew) {
$this->media->update([
'updated_at' => $this->row->dateAdded,
'created_at' => $this->row->dateAdded,
]);
}


// TODO: Add a note if the item already exists (i.e., was imported from goodreads without a note)
if (! $isNew && ! is_null($this->row->notes)) {
$this->media->note = $this->row->notes;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Media extends Model
{
use HasFactory;

protected $fillable = ['year', 'title', 'note', 'media_type_id', 'creator_id'];
protected $fillable = ['year', 'title', 'note', 'media_type_id', 'creator_id', 'created_at', 'updated_at'];

// TODO: Add enum and cast for MediaType

Expand Down

0 comments on commit d11fbd4

Please sign in to comment.