koel/app/Http/Resources/CollaborativeSongResource.php
2024-07-06 17:44:44 +02:00

23 lines
676 B
PHP

<?php
namespace App\Http\Resources;
use Carbon\Carbon;
class CollaborativeSongResource extends SongResource
{
/** @return array<mixed> */
public function toArray($request): array
{
return array_merge(parent::toArray($request), [
'collaboration' => [
'user' => [
'avatar' => gravatar($this->song->collaborator_email),
'name' => $this->song->collaborator_name,
],
'added_at' => $this->song->added_at,
'fmt_added_at' => $this->song->added_at ? Carbon::make($this->song->added_at)->diffForHumans() : null,
],
]);
}
}