@extends('layout.app') @section('content')

{{ $type }} Log History

@forelse ($lists as $log) @php $old = json_decode($log->old_info); $new = json_decode($log->new_info); // Handle smart devices if they exist $oldSmartDevices = []; $newSmartDevices = []; // Handle cancel reasons if they exist $oldCancelReasons = []; $newCancelReasons = []; // Handle survey cancel reasons if they exist $oldSurveyCancelReasons = []; $newSurveyCancelReasons = []; // Process cancel reasons if (isset($old->cancel_reasons) && is_array($old->cancel_reasons)) { $oldCancelReasons = array_filter($old->cancel_reasons, function($reason) { return isset($reason->cancel_reason_id); }); } if (isset($new->cancel_reasons) && is_array($new->cancel_reasons)) { $newCancelReasons = array_filter($new->cancel_reasons, function($reason) { return isset($reason->cancel_reason_id); }); } // Process smart devices if (isset($old->smart_devices) && is_array($old->smart_devices)) { $oldSmartDevices = array_filter($old->smart_devices, function($device) { return isset($device->status) && $device->status === 'Yes'; }); } if (isset($new->smart_devices) && is_array($new->smart_devices)) { $newSmartDevices = array_filter($new->smart_devices, function($device) { return isset($device->status) && $device->status === 'Yes'; }); } // Process survey cancel reasons if (isset($old->survey_cancel_reason) && is_array($old->survey_cancel_reason)) { $oldSurveyCancelReasons = array_filter($old->survey_cancel_reason, function($reason) { return isset($reason->cancel_reason_id); }); } if (isset($new->survey_cancel_reason) && is_array($new->survey_cancel_reason)) { $newSurveyCancelReasons = array_filter($new->survey_cancel_reason, function($reason) { return isset($reason->cancel_reason_id); }); } $change_old = []; $change_new = []; // Compare regular fields foreach ($old as $key => $value) { if ($old->$key != $new->$key && $key != "smart_devices" && $key != 'updated_at' && $key != 'cancel_reasons' && $key != 'survey_cancel_reason') { $change_old[$key] = $old->$key ?? 'N/A'; $change_new[$key] = $new->$key ?? 'N/A'; } } // Add smart devices changes if different if ($oldSmartDevices != $newSmartDevices) { $change_old['smart_devices'] = !empty($oldSmartDevices) ? implode(', ', array_column($oldSmartDevices, 'smart_device_id')) : 'None'; $change_new['smart_devices'] = !empty($newSmartDevices) ? implode(', ', array_column($newSmartDevices, 'smart_device_id')) : 'None'; } // Add cancel reasons changes if different if ($oldCancelReasons != $newCancelReasons) { $change_old['cancel_reasons'] = !empty($oldCancelReasons) ? implode(', ', array_column($oldCancelReasons, 'cancel_reason_id')) : 'None'; $change_new['cancel_reasons'] = !empty($newCancelReasons) ? implode(', ', array_column($newCancelReasons, 'cancel_reason_id')) : 'None'; } // Add survey cancel reasons changes if different (FIXED BUG) if ($oldSurveyCancelReasons != $newSurveyCancelReasons) { $change_old['survey_cancel_reason'] = !empty($oldSurveyCancelReasons) ? implode(', ', array_column($oldSurveyCancelReasons, 'cancel_reason_id')) : 'None'; $change_new['survey_cancel_reason'] = !empty($newSurveyCancelReasons) ? implode(', ', array_column($newSurveyCancelReasons, 'cancel_reason_id')) : 'None'; } @endphp @empty @endforelse
Date & Time Edited By Old Data New Data
{{ $log->created_at->format('d-m-Y') }}
{{ $log->created_at->format('H:i:s') }}
{{ $log->user->name ?? 'N/A' }} @if (!empty($change_old))
@foreach ($change_old as $key => $value)
{{ str_replace('_', ' ', $key) }} : {{ $value }}
@endforeach
@else - @endif
@if (!empty($change_new))
@foreach ($change_new as $key => $value)
{{ str_replace('_', ' ', $key) }} : {{ $value }}
@endforeach
@else - @endif

No history logs found.

@if(method_exists($lists, 'hasPages') && $lists->hasPages()) @endif
@endsection @push('styles') @endpush @section('ajax') @endsection