@php
$formatValue = function($key, $val) use ($activityLog) {
if ($val === null) return 'NULL';
if ($activityLog->log_name !== 'tbl_booking') return $val;
try {
if (in_array($key, ['created_by_id', 'confrimed_by_id', 'booking_creator_id'])) {
$user = \App\Models\TblUser::find($val);
if ($user) return $user->full_name . " (#$val)";
}
elseif ($key === 'state_id') {
$states = \App\Models\TblBooking::getStateOptionsArabic();
if (isset($states[$val])) return $states[$val] . " (#$val)";
}
elseif ($key === 'property_type') {
$pt = \App\Models\PropertyType::find($val);
if ($pt) return ($pt->name_ar ?? $pt->title) . " (#$val)";
}
elseif ($key === 'occasion_type_id') {
$occ = \App\Models\PropertyOccasionType::find($val);
if ($occ) return $occ->name . " (#$val)";
}
} catch (\Exception $e) {}
return $val;
};
@endphp
@if($activityLog->event == 'updated')
| اسم الحقل (Field) |
القيمة السابقة (Old) |
القيمة الحالية (New) |
@if(isset($properties->old) && isset($properties->attributes))
@foreach($properties->old as $key => $value)
@php
$newValue = $properties->attributes->$key ?? null;
$hasChanged = $value != $newValue;
@endphp
@if(gettype($value) != 'array')
| {{ $key }} |
{{ $formatValue($key, $value) }}
|
{{ $formatValue($key, $newValue) }}
|
@endif
@endforeach
@else
| لا تتوفر بيانات للمقارنة |
@endif
@elseif($activityLog->event == 'created')
| اسم الحقل (Field) |
القيمة المُدخلة (Value) |
@if(isset($properties->attributes))
@foreach($properties->attributes as $key => $value)
@if(gettype($value) != 'array')
| {{ $key }} |
{{ $formatValue($key, $value) }}
|
@endif
@endforeach
@else
| لا تتوفر تفاصيل للبيانات |
@endif
@elseif($activityLog->event == 'deleted')
| اسم الحقل (Field) |
القيمة المحذوفة (Value) |
@if(isset($properties->old))
@foreach($properties->old as $key => $value)
@if(gettype($value) != 'array')
| {{ $key }} |
{{ $formatValue($key, $value) }}
|
@endif
@endforeach
@else
| لا تتوفر تفاصيل للبيانات |
@endif
@endif