Files
portal/app/Http/Resources/Image.php
2020-04-18 15:58:48 +02:00

34 lines
804 B
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class Image extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'data' => [
'type' => 'images',
'image_id' => $this->id,
'attributes' => [
'path' => url('storage/'.$this->path),
'width' => $this->width,
'height' => $this->height,
'location' => $this->location,
]
],
'links' => [
'self' => url('/images/'.$this->id),
]
];
}
}