Added created/updated date on assets.
This commit is contained in:
parent
d8e0aaa50f
commit
0231e78941
|
|
@ -4,6 +4,8 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\AssetVersion;
|
||||
use App\Models\User;
|
||||
|
||||
|
|
@ -151,6 +153,28 @@ class Asset extends Model
|
|||
return 'https://gtoria.local/images/testing/hat.png';
|
||||
}
|
||||
|
||||
public function getCreated()
|
||||
{
|
||||
$date = $this['created_at'];
|
||||
if(Carbon::now()->greaterThan($date->copy()->addDays(2)))
|
||||
$date = $date->isoFormat('lll');
|
||||
else
|
||||
$date = $date->calendar();
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getUpdated()
|
||||
{
|
||||
$date = $this['updated_at'];
|
||||
if(Carbon::now()->greaterThan($date->copy()->addDays(2)))
|
||||
$date = $date->isoFormat('lll');
|
||||
else
|
||||
$date = $date->calendar();
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
// Version 0 is internally considered the latest.
|
||||
public function getContent($version = 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,6 +62,24 @@
|
|||
<p>{{ $asset->typeString() }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col-3 fw-bold">
|
||||
<p>Created</p>
|
||||
</div>
|
||||
<div class="col-9">
|
||||
<p>{{ $asset->getCreated() }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@if( $asset->getUpdated() != $asset->getCreated() )
|
||||
<div class="row mt-2">
|
||||
<div class="col-3 fw-bold">
|
||||
<p>Updated</p>
|
||||
</div>
|
||||
<div class="col-9">
|
||||
<p>{{ $asset->getUpdated() }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="row mt-2">
|
||||
<div class="col-3 fw-bold">
|
||||
<p>Description</p>
|
||||
|
|
|
|||
Loading…
Reference in New Issue