mirror of
https://github.com/koel/koel
synced 2024-12-23 19:13:06 +00:00
35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Values\PlaylistCollaborator;
|
|
use Carbon\Carbon;
|
|
|
|
class CollaborativeSongResource extends SongResource
|
|
{
|
|
public const JSON_STRUCTURE = SongResource::JSON_STRUCTURE + [
|
|
'collaboration' => [
|
|
'user' => PlaylistCollaboratorResource::JSON_STRUCTURE,
|
|
'added_at',
|
|
'fmt_added_at',
|
|
],
|
|
];
|
|
|
|
/** @return array<mixed> */
|
|
public function toArray($request): array
|
|
{
|
|
return array_merge(parent::toArray($request), [
|
|
'collaboration' => [
|
|
'user' => PlaylistCollaboratorResource::make(
|
|
PlaylistCollaborator::make(
|
|
$this->song->collaborator_id,
|
|
$this->song->collaborator_name,
|
|
gravatar($this->song->collaborator_email),
|
|
),
|
|
),
|
|
'added_at' => $this->song->added_at,
|
|
'fmt_added_at' => $this->song->added_at ? Carbon::make($this->song->added_at)->diffForHumans() : null,
|
|
],
|
|
]);
|
|
}
|
|
}
|