- added file resource

- frontend refactoring
This commit is contained in:
Peter Papp
2021-08-26 18:01:57 +02:00
parent f5f2179145
commit 5c6a873b02
37 changed files with 339 additions and 773 deletions

View File

@@ -1,6 +1,8 @@
<?php
namespace Domain\Files\Resources;
use Domain\Sharing\Resources\ShareResource;
use Illuminate\Http\Resources\Json\JsonResource;
class FileResource extends JsonResource
@@ -15,19 +17,28 @@ class FileResource extends JsonResource
{
return [
'data' => [
'id' => $this->id,
'type' => 'file',
'attributes' => [
'id' => $this->id,
'type' => $this->type,
'attributes' => [
'name' => $this->name,
'basename' => $this->basename,
'mimetype' => $this->mimetype,
'filesize' => $this->filesize,
'type' => $this->type,
'file_url' => $this->file_url,
'thumbnail' => $this->thumbnail,
'created_at' => $this->created_at,
'updated_at' => $this->created_at,
'metadata' => $this->metadata,
'updated_at' => format_date(
set_time_by_user_timezone($this->updated_at), __t('time')
),
'created_at' => format_date(
set_time_by_user_timezone($this->created_at), __t('time')
),
],
'relationships' => [
$this->mergeWhen($this->shared, fn() => [
'shared' => new ShareResource($this->shared),
]),
]
],
];
}