editHistory.blade.php 1.16 KB
<?php

$edits = [];

if (isset($comment->meta['edited'])) {
    foreach ($comment->meta['edited'] as $edit) {
        $edit = json_decode($edit, true);

        if ($edit['action'] === 'edit') {
            $edits[] = $edit;
        } elseif ($edit['action'] == 'delete' && $user() && $user()->getRole() >= 20) {
            $edits[] = $edit;
        } elseif ($edit['action'] == 'undelete' && $user() && $user()->getRole() >= 20) {
            $edits[] = $edit;
        }
    }
}

?>

@if ($edits)
	<ul class="comment-edit-history">
		@foreach ($edits as $edit)

			@if ($edit['action'] === 'edit')
				<li>{!! date('M j, Y \a\t H:i', strtotime($edit['created_at'])) !!} · comment edited by {!! $edit['username'] !!}</li>
			@elseif ($edit['action'] == 'delete')
				<li>
					{!! date('M j, Y \a\t H:i', strtotime($edit['created_at'])) !!} · comment deleted by {!! $edit['username'] !!}
					
					@if (!empty($edit['reason']))
						for "{!! $edit['reason'] !!}"
					@endif
				</li>
			@elseif ($edit['action']) 
				<li>{!! date('M j, Y \a\t H:i', strtotime($edit['created_at'])) !!} · comment approved by {!! $edit['username'] !!}</li>
			@endif
		
		@endforeach
	</ul>
@endif