FileResource.php refactor

This commit is contained in:
Čarodej
2022-02-25 18:12:14 +01:00
parent 45a46bbc65
commit 6fd8ddf680
3 changed files with 56 additions and 50 deletions
+24 -18
View File
@@ -71,24 +71,30 @@ class FileResource extends JsonResource
],
]),
$this->mergeWhen($this->exif, fn() => [
'metadata' => [
'date_time_original' => format_date($this->exif->date_time_original) ,
'artist' => $this->exif->artist ,
'height' => $this->exif->height,
'width' => $this->exif->width,
'x_resolution' => substr($this->exif->x_resolution, 0, strrpos( $this->exif->x_resolution, '/')),
'y_resolution' => substr($this->exif->y_resolution, 0, strrpos( $this->exif->y_resolution, '/')) ,
'color_space' => $this->exif->color_space ,
'camera' => $this->exif->camera,
'model' => $this->exif->model ,
'aperture_value' => intval($this->exif->aperture_value) / 100 ,
'exposure_time' => $this->exif->exposure_time ,
'focal_length' => $this->exif->focal_length ,
'iso' => $this->exif->iso ,
'aperture_f_number' => $this->exif->aperture_f_number ,
'ccd_width' => $this->exif->ccd_width ,
'longitude' => format_gps_coordinates($this->exif->longitude, $this->exif->longitude_ref) ,
'latitude' => format_gps_coordinates($this->exif->latitude, $this->exif->latitude_ref) ,
'exif' => [
'data' => [
'type' => 'exif',
'id' => $this->exif->id,
'attributes' => [
'date_time_original' => format_date($this->exif->date_time_original),
'artist' => $this->exif->artist,
'height' => $this->exif->height,
'width' => $this->exif->width,
'x_resolution' => substr($this->exif->x_resolution, 0, strrpos($this->exif->x_resolution, '/')),
'y_resolution' => substr($this->exif->y_resolution, 0, strrpos($this->exif->y_resolution, '/')),
'color_space' => $this->exif->color_space,
'camera' => $this->exif->camera,
'model' => $this->exif->model,
'aperture_value' => intval($this->exif->aperture_value) / 100,
'exposure_time' => $this->exif->exposure_time,
'focal_length' => $this->exif->focal_length,
'iso' => $this->exif->iso,
'aperture_f_number' => $this->exif->aperture_f_number,
'ccd_width' => $this->exif->ccd_width,
'longitude' => format_gps_coordinates($this->exif->longitude, $this->exif->longitude_ref),
'latitude' => format_gps_coordinates($this->exif->latitude, $this->exif->latitude_ref),
],
],
]
])
],