Manage calls and the inbox through the API

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 19:42:59 +02:00
parent b02464a7ed
commit 4c65604f04
11 changed files with 890 additions and 1 deletions

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\Application;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Application
*/
class ApplicationResource extends JsonResource
{
/**
* `ip_hash` stays out: it exists to spot the same sender twice, not to be
* handed around.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'kind' => $this->kind->value,
'status' => $this->status->value,
'call_id' => $this->call_id,
'subject' => $this->resource->subject(),
'name' => $this->name,
'email' => $this->email,
'organisation' => $this->organisation,
'message' => $this->message,
'hours_per_week' => $this->hours_per_week,
'links' => (object) ($this->links ?? []),
'locale' => $this->locale,
'notes' => $this->notes,
'handled_by' => $this->whenLoaded('handler', fn () => $this->handler ? [
'id' => $this->handler->id,
'name' => $this->handler->name,
] : null),
'handled_at' => $this->handled_at?->toIso8601String(),
'created_at' => $this->created_at?->toIso8601String(),
'updated_at' => $this->updated_at?->toIso8601String(),
'deleted_at' => $this->deleted_at?->toIso8601String(),
];
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\Call;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Call
*/
class CallResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = $request->query(config('locales.query_parameter')) ?? app()->getLocale();
return [
'id' => $this->id,
'locale' => $locale,
...TranslatablePayload::resolve($this->resource, $this->translatable, $locale),
'status' => $this->status->value,
'hours_per_week' => $this->hours_per_week,
'duration_weeks' => $this->duration_weeks,
'seniority' => $this->seniority,
'opens_at' => $this->opens_at?->toDateString(),
'closes_at' => $this->closes_at?->toDateString(),
'project_id' => $this->project_id,
'technology_ids' => $this->whenLoaded('technologies', fn () => $this->technologies->pluck('id')->values()),
'applications_count' => $this->whenCounted('applications'),
'created_at' => $this->created_at?->toIso8601String(),
'updated_at' => $this->updated_at?->toIso8601String(),
'translations' => $this->when(
in_array('translations', explode(',', (string) $request->query('with')), true),
fn () => TranslatablePayload::all($this->resource, $this->translatable),
),
];
}
}