Skip to content

Commit

Permalink
adds age to the asset table
Browse files Browse the repository at this point in the history
  • Loading branch information
Godmartinz committed Nov 28, 2022
1 parent 078e728 commit 8d861cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Http/Transformers/AssetsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Setting;
use Gate;
use Illuminate\Database\Eloquent\Collection;
use Carbon\Carbon;

class AssetsTransformer
{
Expand Down Expand Up @@ -80,6 +81,7 @@ public function transformAsset(Asset $asset)
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date, 'date'),
'deleted_at' => Helper::getFormattedDateObject($asset->deleted_at, 'datetime'),
'purchase_date' => Helper::getFormattedDateObject($asset->purchase_date, 'date'),
'age' => Carbon::parse($asset->purchase_date)->diff(Carbon::now())->format('%y years, %m months and %d days'),
'last_checkout' => Helper::getFormattedDateObject($asset->last_checkout, 'datetime'),
'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'date'),
'purchase_cost' => Helper::formatCurrencyOutput($asset->purchase_cost),
Expand Down
6 changes: 6 additions & 0 deletions app/Presenters/AssetPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ public static function dataTableLayout()
'visible' => false,
'title' => trans('general.purchase_date'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'age',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.age'),
], [
'field' => 'purchase_cost',
'searchable' => true,
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'admin' => 'Admin',
'administrator' => 'Administrator',
'add_seats' => 'Added seats',
'age' => "Age",
'all_assets' => 'All Assets',
'all' => 'All',
'archived' => 'Archived',
Expand Down

0 comments on commit 8d861cf

Please sign in to comment.