Skip to content

Commit a750224

Browse files
committed
Add support for html content in change display value
1 parent 3dd1714 commit a750224

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

formwidgets/logbook/partials/_logbook.htm

+13-5
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,20 @@
3434
<?php if ($changes->isTypeUpdated()): ?>
3535
: <br/>
3636
<?php foreach ($changes->getChangedAttributes() as $attribute): ?>
37-
<?= e(trans('jacob.logbook::lang.changes.column', [
37+
<?php
38+
$from = $currentModel->changeLogBookDisplayValue($attribute->getColumn(), $attribute->getOld()) ?? '-';
39+
$from = $from instanceof Illuminate\Contracts\Support\Htmlable ? $from->toHtml() : e($from);
40+
41+
$to = $currentModel->changeLogBookDisplayValue($attribute->getColumn(), $attribute->getNew()) ?? '-';
42+
$to = $from instanceof Illuminate\Contracts\Support\Htmlable ? $to->toHtml() : e($to);
43+
?>
44+
45+
<?= trans('jacob.logbook::lang.changes.column', [
3846
'column' => trans($currentModel->changeLogBookDisplayColumn($attribute->getColumn())),
39-
'from' => $currentModel->changeLogBookDisplayValue($attribute->getColumn(), $attribute->getOld()) ?? '-',
40-
'to' => $currentModel->changeLogBookDisplayValue($attribute->getColumn(), $attribute->getNew()) ?? '-'
41-
])) ?>
42-
<br/>
47+
'from' => $from,
48+
'to' => $to
49+
]) ?>
50+
<br/>
4351
<?php endforeach ?>
4452
<?php endif; ?>
4553
</td>

traits/LogChanges.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Backend\Classes\AuthManager;
66
use Backend\Models\User;
77
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
8+
use Illuminate\Contracts\Support\Htmlable;
89
use Jacob\LogBook\Classes\LoadRelation;
910
use Jacob\Logbook\Models\Log;
1011
use Jacob\LogBook\Classes\Entities\Attribute;
@@ -62,7 +63,7 @@ trait LogChanges
6263
*
6364
* @param $column
6465
* @param $value
65-
* @return string
66+
* @return string|Htmlable
6667
*/
6768
public static function changeLogBookDisplayValue($column, $value)
6869
{

0 commit comments

Comments
 (0)