Manage calls and the inbox through the API
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
49
app/Http/Resources/ApplicationResource.php
Normal file
49
app/Http/Resources/ApplicationResource.php
Normal 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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user