@php use App\Helpers\BengaliDateHelper; @endphp @extends('layout.admin') @section('css') @endsection @section('content')

Content History Content ID: #{{ $bnContent->id }}

{{ $bnContent->heading }}

    @foreach ($bnContent->histories as $history)
  • {{ BengaliDateHelper::formatBengaliDateTime($history->created_at) }}
  • @php $iconClass = 'fa-info bg-gray'; $badgeClass = 'bg-gray'; if ($history->action == 'create') { $iconClass = 'fa-plus bg-blue'; $badgeClass = 'bg-create'; } elseif ($history->action == 'update') { $iconClass = 'fa-pencil bg-yellow'; $badgeClass = 'bg-update'; } elseif ($history->action == 'delete') { $iconClass = 'fa-trash bg-red'; $badgeClass = 'bg-delete'; } elseif ($history->action == 'restore') { $iconClass = 'fa-refresh bg-green'; $badgeClass = 'bg-restore'; } @endphp

    {{ $history->user->name ?? 'System' }} {{ $history->action }} {{-- {{ $history->created_at->format('h:i A') }} --}}

    @if ($history->changes && count($history->changes) > 0)
    @foreach ($history->changes as $field => $change) @php $resolveValue = function ($field, $val) use ($idToNameMap) { if (is_null($val) || $val === '') { return '(Empty)'; } if ( in_array($field, [ 'category_id', 'sub_category_id', 'special_category_id', 'writer_id', 'district_id', 'upazila_id', ]) ) { return $idToNameMap[$field][$val] ?? "ID: $val"; } if ( in_array($field, [ 'created_by', 'updated_by', 'editing_by_id', ]) ) { return $idToNameMap['user_id'][$val] ?? "User ID: $val"; } if (in_array($field, ['tag_ids', 'TagIDs'])) { $tagIds = explode(',', $val); $names = []; foreach ($tagIds as $tid) { if (is_numeric($tid)) { $names[] = $idToNameMap['TagIDs'][$tid] ?? "#$tid"; } } return !empty($names) ? implode(', ', $names) : "IDs: $val"; } if ($field === 'secondary_category_ids') { $catIds = explode(',', $val); $names = []; foreach ($catIds as $cid) { if (is_numeric($cid)) { $names[] = $idToNameMap['category_id'][$cid] ?? "#$cid"; } } return !empty($names) ? implode(', ', $names) : "IDs: $val"; } return is_array($val) ? json_encode($val, JSON_UNESCAPED_UNICODE) : $val; }; @endphp @endforeach
    Field Name Previous State Updated State
    {{ ucwords(str_replace('_', ' ', $field)) }} {!! $resolveValue($field, $change['old']) !!} {!! $resolveValue($field, $change['new']) !!}
    @endif
  • @endforeach @if (!$hasCreateAction)
  • {{ BengaliDateHelper::formatBengaliDateTime($bnContent->created_at) }}
  • {{ $bnContent->creator->name ?? ($bnContent->created_by ?? 'N/A') }} Initial Creation Legacy Row

    This content was created before history tracking was fully active.

  • @endif
@endsection