Files
portal/app/app/Http/Resources/ProjectResource.php
T
2026-05-11 18:08:01 +03:00

44 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\Project;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin Project */
class ProjectResource extends JsonResource
{
public function toArray(Request $request): array
{
/** @var Project $project */
$project = $this->resource;
return [
'id' => $this->id,
'name' => $this->name,
'signal_type' => $this->signal_type,
'signal_identifier' => $this->signal_identifier,
'sms_senders' => $this->sms_senders,
'sms_keyword' => $this->sms_keyword,
'daily_limit_target' => $this->daily_limit_target,
'effective_daily_limit_today' => $this->effective_daily_limit_today,
'delivered_today' => $this->delivered_today,
'delivered_in_month' => $this->delivered_in_month,
'is_active' => $this->is_active,
'archived_at' => $project->archived_at?->toIso8601String(),
'region_mask' => $this->region_mask,
'region_mode' => $this->region_mode,
'delivery_days_mask' => $this->delivery_days_mask,
'sync_status' => $this->aggregateSyncStatus(),
'last_synced_at' => $this->aggregateLastSyncedAt(),
'supplier_links' => $this->when(
$request->routeIs('projects.show'),
fn () => $this->getSupplierLinks(),
),
];
}
}