A free open source IT asset/license management system
New transformers
snipe282388fb3301
diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.phpindex f08704039e..2a0ed24926 100644--- a/app/Http/Transformers/AssetsTransformer.php+++ b/app/Http/Transformers/AssetsTransformer.php@@ -6,6 +6,8 @@ use App\Helpers\Helper;use App\Models\Accessory;use App\Models\AccessoryCheckout;use App\Models\Asset;+use App\Models\License;+use App\Models\LicenseSeat;use App\Models\Setting;use Carbon\Carbon;use Illuminate\Database\Eloquent\Collection;@@ -341,4 +343,68 @@ class AssetsTransformerreturn $array;}}++ public function transformLicensesCheckedToAsset($license_checkouts, $total)+ {++ $array = [];+ foreach ($license_checkouts as $checkout) {+ $array[] = self::transformLicenseCheckedToAsset($checkout);+ }++ return (new DatatablesTransformer)->transformDatatables($array, $total);+ }++ public function transformLicenseCheckedToAsset(LicenseSeat $licenseseat)+ {++ if (Gate::allows('viewKeys', $licenseseat->license)) {+ $product_key = $licenseseat->license->serial ?? null;+ } else {+ $product_key = '------------';+ }++ $array = [+ 'id' => $licenseseat->id,+ 'license' => [+ 'id' => $licenseseat->license?->id,+ 'name' => e($licenseseat->license?->display_name),+ 'serial' => $product_key ? e($product_key) : null,+ 'note' => $licenseseat->license?->note ? e($licenseseat->license?->note) : null,++ ],+ 'assigned_asset' => $licenseseat->asset_id,+ 'expiration_date' => $licenseseat->license?->expiration_date ? Helper::getFormattedDateObject($licenseseat->license?->expiration_date, 'date') : null,+ 'notes' => $licenseseat->notes ? e($licenseseat->notes) : null,+ ];++ $permissions_array['available_actions'] = [+ 'checkout' => false,+ 'checkin' => Gate::allows('checkin', License::class),+ ];++ $array += $permissions_array;++ return $array;++ }++ public function transformCheckedoutComponents(Collection $components_assets, $total)+ {+ $array = [];+ foreach ($components_assets as $component) {+ $array[] = [+ 'assigned_pivot_id' => $component->pivot->id,+ 'id' => (int) $component->id,+ 'name' => e($component->display_name),+ 'qty' => $component->pivot->assigned_qty,+ 'note' => ($component->pivot->note) ? e($component->pivot->note) : null,+ 'type' => 'asset',+ 'created_at' => Helper::getFormattedDateObject($component->pivot->created_at, 'datetime'),+ 'available_actions' => ['checkin' => true],+ ];+ }++ return (new DatatablesTransformer)->transformDatatables($array, $total);+ }}diff --git a/app/Http/Transformers/ComponentsTransformer.php b/app/Http/Transformers/ComponentsTransformer.phpindex 219e6e6e6f..a45f30558a 100644--- a/app/Http/Transformers/ComponentsTransformer.php+++ b/app/Http/Transformers/ComponentsTransformer.php@@ -89,9 +89,9 @@ class ComponentsTransformer$array[] = ['assigned_pivot_id' => $asset->pivot->id,'id' => (int) $asset->id,- 'name' => e($asset->model->display_name).' '.e($asset->display_name),+ 'name' => e($asset->display_name),'qty' => $asset->pivot->assigned_qty,- 'note' => e($asset->pivot->note),+ 'note' => ($asset->pivot->note) ? e($asset->pivot->note) : null,'type' => 'asset','created_at' => Helper::getFormattedDateObject($asset->pivot->created_at, 'datetime'),'available_actions' => ['checkin' => true],diff --git a/app/Http/Transformers/LicenseSeatsTransformer.php b/app/Http/Transformers/LicenseSeatsTransformer.phpindex f218b0631e..08ce3e8bcc 100644--- a/app/Http/Transformers/LicenseSeatsTransformer.php+++ b/app/Http/Transformers/LicenseSeatsTransformer.php@@ -54,7 +54,7 @@ class LicenseSeatsTransformer] : null,'location' => ($seat->location()) ? ['id' => (int) $seat->location()->id,- 'name' => e($seat->location()->name),+ 'name' => e($seat->location()->display_name),'tag_color' => $seat->location()->tag_color ? e($seat->location()->tag_color) : null,'created_at' => Helper::getFormattedDateObject($seat->created_at, 'datetime'),] : null,