Use a timestamp function to version dashboard edit-item assets

This commit is contained in:
Kevin MacMartin 2018-04-23 23:13:40 -04:00
parent d0c85bd453
commit 10f11f8480
2 changed files with 12 additions and 4 deletions

View file

@ -168,4 +168,13 @@ class DashboardModel extends Model
return $user_check; return $user_check;
} }
/**
* Returns the Unix timestamp of the latest update
*
* @return number
*/
public function timestamp() {
return strtotime($this->updated_at);
}
} }

View file

@ -53,7 +53,7 @@
@if(file_exists(base_path() . '/public' . $current_image)) @if(file_exists(base_path() . '/public' . $current_image))
<div id="current-image-{{ $column['name'] }}"> <div id="current-image-{{ $column['name'] }}">
<img class="current-image" src="{{ $current_image }}?version={{ env('CACHE_BUST') }}" /> <img class="current-image" src="{{ $current_image }}?version={{ $item->timestamp() }}" />
@if(array_key_exists('delete', $column) && $column['delete']) @if(array_key_exists('delete', $column) && $column['delete'])
<span class="edit-button delete image" data-name="{{ $column['name'] }}"> <span class="edit-button delete image" data-name="{{ $column['name'] }}">
@ -63,13 +63,12 @@
</div> </div>
@endif @endif
@elseif($column['type'] == 'file') @elseif($column['type'] == 'file')
<input class="file-upload" type="file" name="{{ $column['name'] }}" id="{{ $column['name'] }}" data-ext="{{ $column['ext'] }}" />
@set('current_file', "/uploads/$model/files/$id-" . $column['name'] . '.' . $column['ext']) @set('current_file', "/uploads/$model/files/$id-" . $column['name'] . '.' . $column['ext'])
<input class="file-upload" type="file" name="{{ $column['name'] }}" id="{{ $column['name'] }}" data-ext="{{ $column['ext'] }}" />
@if(file_exists(base_path() . '/public' . $current_file)) @if(file_exists(base_path() . '/public' . $current_file))
<div id="current-file-{{ $column['name'] }}"> <div id="current-file-{{ $column['name'] }}">
<a class="edit-button view" href="{{ $current_file }}" target="_blank">View {{ strtoupper($column['ext']) }}</a> <a class="edit-button view" href="{{ $current_file }}?version={{ $item->timestamp() }}" target="_blank">View {{ strtoupper($column['ext']) }}</a>
@if(array_key_exists('delete', $column) && $column['delete']) @if(array_key_exists('delete', $column) && $column['delete'])
<span class="edit-button delete file" data-name="{{ $column['name'] }}" data-ext="{{ $column['ext'] }}"> <span class="edit-button delete file" data-name="{{ $column['name'] }}" data-ext="{{ $column['ext'] }}">