Skip to content

Commit

Permalink
Added raw values of some attributes which are required by other front…
Browse files Browse the repository at this point in the history
… ends than the web front end
  • Loading branch information
nagmat84 committed May 2, 2021
1 parent 82d1081 commit d5d3f54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Models/Extensions/AlbumCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ public function toReturnArray(): array
'share_button_visible' => Helpers::str_of_bool($this->is_share_button_visible()),

// Parse date
// The raw takestamps are used by clients which localize date/times at the GUI layer
// The formatted takestamps are currently used by the web frontend
// Maybe, it would be reasonable to migrate the web frontend to use the raw formats, too
// and let JavaScript do the localization at the client side
'sysdate' => $this->created_at->format('F Y'),
'created_at_raw' => $this->created_at->timestamp,
'min_takestamp' => $this->str_min_takestamp(),
'min_takestamp_raw' => $this->min_takestamp !== null ? $this->min_takestamp->timestamp : null,
'max_takestamp' => $this->str_max_takestamp(),
'max_takestamp_raw' => $this->max_takestamp !== null ? $this->max_takestamp->timestamp : null,
'updated_at_raw' => $this->updated_at !== null ? $this->updated_at->timestamp : null,

// Parse password
'password' => Helpers::str_of_bool($this->password != ''),
Expand Down
5 changes: 5 additions & 0 deletions app/Models/Extensions/PhotoCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public function toReturnArray(): array
'public' => $this->get_public(),
'album' => $this->album_id !== null ? strval($this->album_id) : null,
'width' => strval($this->width),
'width_raw' => $this->width !== null ? $this->width : -1,
'height' => strval($this->height),
'height_raw' => $this->height !== null ? $this->height : -1,
'type' => $this->type,
'size' => $this->size,
'iso' => $this->iso,
Expand All @@ -42,7 +44,10 @@ public function toReturnArray(): array
'livePhotoContentID' => $this->livePhotoContentID,

'sysdate' => $this->created_at->format('d F Y \a\t H:i'),
'created_at_raw' => $this->created_at->timestamp,
'takedate' => isset($this->takestamp) ? $this->takestamp->format('d F Y \a\t H:i') : '',
'takestamp_raw' => isset($this->takestamp) ? $this->takestamp->timestamp : null,
'updated_at_raw' => isset($this->updated_at) ? $this->updated_at->timestamp : null,
'license' => $this->license,
];
}
Expand Down

0 comments on commit d5d3f54

Please sign in to comment.