Files
core/app/Handlers/History.php
T

48 lines
1.7 KiB
PHP

<?php
namespace App\Handlers;
use App\Enumerations\ContentStatuses;
use App\Handlers\Contracts\HistoryHandler;
use App\Helpers\Differ;
class History implements HistoryHandler
{
public static function parseColumnName($column)
{
return trans('admin/history.column' . ucfirst($column));
}
public static function parseChangedValue($changeset)
{
switch ($changeset->column) {
case 'pageContent':
$route = route('history.diff', [
'revision' => $changeset->edit_batch,
'id' => $changeset->id
]);
return "(<a href='" . $route . "'>" . trans('admin/history.diff') . "</a>)";
break;
case 'metaDescription':
return Differ::htmlDiff($changeset->old_value, $changeset->new_value);
break;
case 'status':
$statuses = ContentStatuses::getWithTranslations();
return trans('admin/history.changedFromTo', [
'from' => $statuses[$changeset->old_value],
'to' => $statuses[$changeset->new_value]
]);
break;
case 'is_homepage':
return trans('admin/history.setupAsHomepage');
break;
default:
return trans('admin/history.changedFromTo', [
'from' => is_null($changeset->old_value) ? trans('admin/history.emptyValue') : $changeset->old_value,
'to' => is_null($changeset->new_value) ? trans('admin/history.emptyValue') : $changeset->new_value,
]);
break;
}
}
}