Files
portal/app/database/factories/SupplierSyncLogFactory.php
T
Дмитрий 084a952bfa feat(models): add SupplierSyncLog model + factory (audit trail для AJAX-sync)
- app/Models/SupplierSyncLog.php — fillable + casts (jsonb arrays + datetime)
  + supplierProject() BelongsTo relation (nullable, ON DELETE SET NULL —
    лог переживает удаление supplier-проекта для audit-trail).
  $timestamps = false (только created_at, без updated_at — append-only)
- database/factories/SupplierSyncLogFactory.php — реалистичные действия из enum
- tests/Feature/Models/SupplierSyncLogTest.php — 4 теста: factory,
  supplier_project relation, jsonb array casts, nullable FK lifecycle

Pest: 463 / 461 passed / 2 skipped (457 + 4 новых = 461).
Larastan: 0 errors. Pint passed.

Spec: §4.3
Plan: Task 9

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 16:53:55 +03:00

31 lines
779 B
PHP

<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\SupplierSyncLog;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SupplierSyncLog>
*/
class SupplierSyncLogFactory extends Factory
{
protected $model = SupplierSyncLog::class;
public function definition(): array
{
return [
'supplier_project_id' => null,
'action' => fake()->randomElement(['create', 'update', 'delete', 'disable', 'session_refresh']),
'request_payload' => ['stub' => true],
'response_body' => null,
'http_status' => 200,
'error_message' => null,
'duration_ms' => fake()->numberBetween(50, 5000),
'created_at' => now(),
];
}
}