Update AdminUser, fix entity casting

This commit is contained in:
Daniel Supernault 2024-07-17 02:24:16 -06:00
parent 28e2985f77
commit cb5620d4c0
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -2,8 +2,8 @@
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Services\AccountService;
use Illuminate\Http\Resources\Json\JsonResource;
class AdminUser extends JsonResource
{
@ -18,8 +18,8 @@ class AdminUser extends JsonResource
$account = AccountService::get($this->profile_id, true);
$res = [
'id' => $this->id,
'profile_id' => $this->profile_id,
'id' => (string) $this->id,
'profile_id' => (string) $this->profile_id,
'name' => $this->name,
'username' => $this->username,
'is_admin' => (bool) $this->is_admin,
@ -28,6 +28,7 @@ class AdminUser extends JsonResource
'two_factor_enabled' => (bool) $this->{'2fa_enabled'},
'register_source' => $this->register_source,
'app_register_ip' => $this->app_register_ip,
'has_interstitial' => (bool) $this->has_interstitial,
'last_active_at' => $this->last_active_at,
'created_at' => $this->created_at,
];
@ -35,10 +36,10 @@ class AdminUser extends JsonResource
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'];
$res['statuses_count'] = (int) $account['statuses_count'];
$res['following_count'] = (int) $account['following_count'];
$res['followers_count'] = (int) $account['followers_count'];
$res['is_private'] = (bool) $account['locked'];
}
return $res;