Files
sam-manage/app/Models/Audit/TriggerAuditLog.php
김보곤 8291cdc39b feat: [database] codebridge DB 분리 - 118개 MNG 전용 테이블 connection 설정
- config/database.php에 codebridge connection 추가
- 78개 MNG 전용 모델에 $connection = 'codebridge' 설정
  - Admin (15): PM, 로드맵, API Explorer
  - Sales (16): 영업파트너, 수수료, 가망고객
  - Finance (9): 법인카드, 자금관리, 홈택스
  - Barobill (12): 은행/카드 동기화 관리
  - Interview (1), ESign (6), Equipment (2)
  - AI (3), Audit (3), 기타 (11)
2026-03-07 11:31:27 +09:00

61 lines
1.4 KiB
PHP

<?php
namespace App\Models\Audit;
use Illuminate\Database\Eloquent\Model;
class TriggerAuditLog extends Model
{
protected $connection = 'codebridge';
protected $table = 'trigger_audit_logs';
public $timestamps = false;
protected $casts = [
'old_values' => 'array',
'new_values' => 'array',
'changed_columns' => 'array',
'created_at' => 'datetime',
];
/**
* changed_columns에서 NULL 값 제거
*/
public function getChangedColumnsAttribute($value): ?array
{
$decoded = is_string($value) ? json_decode($value, true) : $value;
if (! is_array($decoded)) {
return null;
}
return array_values(array_filter($decoded, fn ($v) => $v !== null));
}
/**
* session_info JSON → array
*/
public function getSessionInfoAttribute($value): ?array
{
if (! $value) {
return null;
}
return is_string($value) ? json_decode($value, true) : $value;
}
public function scopeForTable($query, string $tableName)
{
return $query->where('table_name', $tableName);
}
public function scopeForRecord($query, string $tableName, string $rowId)
{
return $query->where('table_name', $tableName)->where('row_id', $rowId);
}
public function scopeForOperation($query, string $operationId)
{
return $query->where('operation_id', $operationId);
}
}