You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelfed/app/Http/Resources/DirectoryProfile.php

45 lines
1.1 KiB
PHTML

<?php
namespace App\Http\Resources;
use App\Services\AccountService;
4 weeks ago
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Http\Request;
9 months ago
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @property int $id
* @property string|null $name
* @property string $username
*/
class DirectoryProfile extends JsonResource
{
9 months ago
/**
* Transform the resource into an array.
*
4 weeks ago
* @param Request $request
* @return array|Arrayable|\JsonSerializable
9 months ago
*/
public function toArray($request)
{
$account = AccountService::get($this->id, true);
if (! $account) {
return [];
}
$url = url($this->username);
9 months ago
return [
'id' => $this->id,
'name' => $this->name,
'username' => $this->username,
'url' => $url,
'avatar' => $account['avatar'],
'following_count' => $account['following_count'],
'followers_count' => $account['followers_count'],
'statuses_count' => $account['statuses_count'],
'bio' => $account['note_text'],
];
}
}