mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-19 21:11:26 +00:00
commit
7cde1e5b90
1 changed files with 44 additions and 0 deletions
44
app/Http/Resources/AdminUser.php
Normal file
44
app/Http/Resources/AdminUser.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
use App\Services\AccountService;
|
||||||
|
|
||||||
|
class AdminUser extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$account = AccountService::get($this->profile_id, true);
|
||||||
|
|
||||||
|
$res = [
|
||||||
|
'id' => $this->id,
|
||||||
|
'profile_id' => $this->profile_id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'username' => $this->username,
|
||||||
|
'is_admin' => (bool) $this->is_admin,
|
||||||
|
'email_verified_at' => $this->email_verified_at,
|
||||||
|
'two_factor_enabled' => (bool) $this->{'2fa_enabled'},
|
||||||
|
'register_source' => $this->register_source,
|
||||||
|
'last_active_at' => $this->last_active_at,
|
||||||
|
'created_at' => $this->created_at,
|
||||||
|
];
|
||||||
|
|
||||||
|
if($account) {
|
||||||
|
$res['avatar'] = $account['avatar'];
|
||||||
|
$res['bio'] = $account['note_text'];
|
||||||
|
$res['statuses_count'] = $account['statuses_count'];
|
||||||
|
$res['following_count'] = $account['following_count'];
|
||||||
|
$res['followers_count'] = $account['followers_count'];
|
||||||
|
$res['is_private'] = $account['locked'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue