a4601fe84b
Старт closing «Notification delivery» из карты P0. Этап 1/6 плана: NotificationService + Mailable + интеграция в ProcessWebhookJob::chargeNewLead. - App\Services\NotificationService — диспетчер 8 событий × 3 каналов (inapp/push/email) согласно schema.sql:699 users.notification_preferences. Этап 1 реализует только email-канал для new_lead. - App\Mail\NewLeadNotification + emails/new_lead.blade.php — HTML-письмо в Forest-палитре с таблицей phone/contact_name/received_at/deal_id. - ProcessWebhookJob::chargeNewLead — после ActivityLog вызывает notifyNewLead. Throwable от Mail::send проглатывается + Log::warning (отказ канала не должен валить транзакцию). - Pest 11/11 в tests/Feature/Notifications/NewLeadNotificationTest.php: email=true получает / email=false не получает / schema-default не шлёт / inactive не получает / soft-deleted не получает / другой тенант не получает / Биз-19 дубль не дублирует / повторный vid не дублирует / balance=0 не шлёт / subject содержит project_name. - IDE-helper регенерирован (4 модели получили @mixin docblocks). - PHPStan baseline регенерирован (138 ignore.unmatched схлопнулись). Pest 280/280 за 31.27 сек (+11 от 269, 1029 assertions). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* Append-only audit-лог действий SaaS-админов (schema v8.7 §10 / table
|
|
* saas_admin_audit_log). Hash-chain trigger BEFORE INSERT заполняет log_hash
|
|
* автоматически (OPEN-И-15 tamper-detection).
|
|
*
|
|
* Без RLS — таблица доступна только из crm_admin_user (BYPASSRLS) +
|
|
* crm_audit_writer (INSERT-only).
|
|
*
|
|
* @property int $id
|
|
* @property int $admin_user_id
|
|
* @property string $action
|
|
* @property string|null $target_type
|
|
* @property int|null $target_id
|
|
* @property int|null $target_tenant_id
|
|
* @property array<string,mixed>|null $payload_before
|
|
* @property array<string,mixed>|null $payload_after
|
|
* @property string|null $reason
|
|
* @property string $ip_address
|
|
* @property string|null $user_agent
|
|
* @property bool $requires_approval
|
|
* @property int|null $approved_by
|
|
* @property Carbon|null $approved_at
|
|
* @property Carbon $created_at
|
|
*
|
|
* @mixin IdeHelperSaasAdminAuditLog
|
|
*/
|
|
class SaasAdminAuditLog extends Model
|
|
{
|
|
protected $table = 'saas_admin_audit_log';
|
|
|
|
/** Append-only — без updated_at. */
|
|
public const UPDATED_AT = null;
|
|
|
|
protected $fillable = [
|
|
'admin_user_id',
|
|
'action',
|
|
'target_type',
|
|
'target_id',
|
|
'target_tenant_id',
|
|
'payload_before',
|
|
'payload_after',
|
|
'reason',
|
|
'ip_address',
|
|
'user_agent',
|
|
'requires_approval',
|
|
'approved_by',
|
|
'approved_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'payload_before' => 'array',
|
|
'payload_after' => 'array',
|
|
'requires_approval' => 'boolean',
|
|
'approved_at' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
];
|
|
}
|
|
}
|