pixelfed/app/Http/Resources/Admin/AdminModeratedProfileResource.php

46 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2024-10-15 10:31:09 +00:00
<?php
namespace App\Http\Resources\Admin;
2024-10-15 10:31:40 +00:00
use App\Profile;
2024-10-15 10:31:09 +00:00
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class AdminModeratedProfileResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$profileObj = [];
$profile = Profile::withTrashed()->find($this->profile_id);
2024-10-15 10:31:40 +00:00
if ($profile) {
2024-10-15 10:31:09 +00:00
$profileObj = [
2024-10-18 08:43:09 +00:00
'name' => $profile->name,
2024-10-15 10:31:09 +00:00
'username' => $profile->username,
2024-10-18 08:43:09 +00:00
'username_str' => explode('@', $profile->username)[1],
'remote_url' => $profile->remote_url,
2024-10-15 10:31:09 +00:00
];
}
2024-10-15 10:31:40 +00:00
2024-10-15 10:31:09 +00:00
return [
'id' => $this->id,
'domain' => $this->domain,
'profile' => $profileObj,
'profile_id' => $this->profile_id,
'profile_url' => $this->profile_url,
'note' => $this->note,
'is_banned' => (bool) $this->is_banned,
'is_nsfw' => (bool) $this->is_nsfw,
'is_unlisted' => (bool) $this->is_unlisted,
'is_noautolink' => (bool) $this->is_noautolink,
'is_nodms' => (bool) $this->is_nodms,
'is_notrending' => (bool) $this->is_notrending,
2024-10-18 09:54:20 +00:00
'created_at' => now()->parse($this->created_at)->format('c'),
2024-10-15 10:31:09 +00:00
];
}
}