2026-05-11 18:08:01 +03:00
|
|
|
<?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
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
'region_mask' => $this->region_mask,
|
|
|
|
|
'region_mode' => $this->region_mode,
|
2026-05-17 10:05:32 +03:00
|
|
|
'regions' => $this->regions,
|
2026-05-11 18:08:01 +03:00
|
|
|
'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(),
|
|
|
|
|
),
|
2026-05-28 07:02:49 +03:00
|
|
|
// Task 2.11 (Spec §4.2.5): dynamic attribute, не БД-поле. Установлен
|
|
|
|
|
// ProjectService::update() для slepok-sensitive правок. UI показывает
|
|
|
|
|
// «изменения вступят в силу с DD.MM HH:MM МСК».
|
|
|
|
|
'applies_from' => $this->applies_from?->toIso8601String(),
|
2026-05-11 18:08:01 +03:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|