b1e903f31a
C1: ProjectResource не возвращал regions → edit-диалог/drawer затирали
сохранённые регионы при сохранении. +поле в toArray().
C2: +integration-тест outbound regions[] через полный SyncSupplierProjectsJob::handle().
I1: расскип NewProjectDialog payload-теста (regions в POST).
I2: assert data.regions в ProjectsStore/UpdateTest (ловит C1 на backend-уровне).
I4: docblock — bulkUpdateRegions legacy (region_mask, не влияет на outbound до Plan 6.5).
M1: CHANGELOG v8.22 — исправлен неверный пример регионов (Москва=82).
Регрессия: Pest 905/902/3sk/0, Vitest 104f/884/3sk/0.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.5 KiB
PHP
45 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,
|
|
'regions' => $this->regions,
|
|
'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(),
|
|
),
|
|
];
|
|
}
|
|
}
|