mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
Brings the API in close sync to the rest of the site. - Adds resources for License, UserRole, and ModVersion models - Adds filtering on attribute data - The `includes` data is now disabled by default and available conditionally
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api\V0;
|
|
|
|
use App\Http\Controllers\Api\V0\ApiController;
|
|
use App\Models\User;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/** @mixin User */
|
|
class UserResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'type' => 'user',
|
|
'id' => $this->id,
|
|
'attributes' => [
|
|
'name' => $this->name,
|
|
'user_role_id' => $this->user_role_id,
|
|
'created_at' => $this->created_at,
|
|
'updated_at' => $this->updated_at,
|
|
],
|
|
'relationships' => [
|
|
'user_role' => [
|
|
'data' => [
|
|
'type' => 'user_role',
|
|
'id' => $this->user_role_id,
|
|
],
|
|
],
|
|
],
|
|
'includes' => $this->when(
|
|
ApiController::shouldInclude('user_role'),
|
|
new UserRoleResource($this->role)
|
|
),
|
|
'links' => [
|
|
'self' => $this->profileUrl(),
|
|
],
|
|
];
|
|
}
|
|
}
|