feat: person tags system - org-level skills with self-reported and organiser-assigned sources
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,23 @@ final class PersonResource extends JsonResource
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
'crowd_type' => new CrowdTypeResource($this->whenLoaded('crowdType')),
|
||||
'company' => new CompanyResource($this->whenLoaded('company')),
|
||||
'tags' => $this->when(
|
||||
$this->user_id && $this->relationLoaded('user'),
|
||||
function () {
|
||||
$orgId = $this->event?->organisation_id;
|
||||
if (!$orgId || !$this->user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return UserOrganisationTagResource::collection(
|
||||
$this->user->organisationTags()
|
||||
->where('organisation_id', $orgId)
|
||||
->with('personTag')
|
||||
->get()
|
||||
);
|
||||
},
|
||||
[]
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
27
api/app/Http/Resources/Api/V1/PersonTagResource.php
Normal file
27
api/app/Http/Resources/Api/V1/PersonTagResource.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\Api\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class PersonTagResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'organisation_id' => $this->organisation_id,
|
||||
'name' => $this->name,
|
||||
'category' => $this->category,
|
||||
'icon' => $this->icon,
|
||||
'color' => $this->color,
|
||||
'is_active' => $this->is_active,
|
||||
'sort_order' => $this->sort_order,
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
'updated_at' => $this->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\Api\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class UserOrganisationTagResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'person_tag' => [
|
||||
'id' => $this->personTag->id,
|
||||
'name' => $this->personTag->name,
|
||||
'category' => $this->personTag->category,
|
||||
'icon' => $this->personTag->icon,
|
||||
'color' => $this->personTag->color,
|
||||
],
|
||||
'source' => $this->source,
|
||||
'proficiency' => $this->proficiency,
|
||||
'notes' => $this->notes,
|
||||
'assigned_at' => $this->assigned_at->toIso8601String(),
|
||||
'assigned_by' => $this->when(
|
||||
$this->source === 'organiser_assigned' && $this->relationLoaded('assignedBy') && $this->assignedBy,
|
||||
fn () => ['id' => $this->assignedBy->id, 'name' => $this->assignedBy->name],
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user