mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-13 00:54:07 -08:00
5290c47e2a
# Conflicts: # .env.example # .travis.yml # Dockerfile # README.md # app/Console/Commands/LdapSync.php # app/Console/Kernel.php # app/Http/Controllers/AccessoriesController.php # app/Http/Controllers/Api/AccessoriesController.php # app/Http/Controllers/Api/AssetsController.php # app/Http/Controllers/Api/LocationsController.php # app/Http/Controllers/Api/SettingsController.php # app/Http/Controllers/Api/UsersController.php # app/Http/Controllers/AssetModelsController.php # app/Http/Controllers/Assets/AssetFilesController.php # app/Http/Controllers/Assets/AssetsController.php # app/Http/Controllers/CategoriesController.php # app/Http/Controllers/CompaniesController.php # app/Http/Controllers/ComponentsController.php # app/Http/Controllers/ConsumablesController.php # app/Http/Controllers/DepartmentsController.php # app/Http/Controllers/LicensesController.php # app/Http/Controllers/LocationsController.php # app/Http/Controllers/ManufacturersController.php # app/Http/Controllers/ReportsController.php # app/Http/Controllers/SettingsController.php # app/Http/Controllers/SuppliersController.php # app/Http/Controllers/UsersController.php # app/Http/Middleware/EncryptCookies.php # app/Http/Requests/AssetRequest.php # app/Http/Transformers/AssetMaintenancesTransformer.php # app/Importer/AssetImporter.php # app/Models/AssetMaintenance.php # app/Models/Location.php # app/Models/User.php # composer.json # composer.lock # config/backup.php # config/database.php # config/version.php # public/mix-manifest.json # resources/lang/en-ID/general.php # resources/lang/vi/admin/settings/general.php # resources/views/accessories/edit.blade.php # resources/views/hardware/view.blade.php # resources/views/layouts/default.blade.php # tests/api/ApiCategoriesCest.php
76 lines
3.4 KiB
PHP
76 lines
3.4 KiB
PHP
<?php
|
|
namespace App\Http\Transformers;
|
|
|
|
use App\Helpers\Helper;
|
|
use App\Models\AssetMaintenance;
|
|
use Gate;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use App\Helpers\Helper;
|
|
use App\Models\Asset;
|
|
|
|
class AssetMaintenancesTransformer
|
|
{
|
|
|
|
public function transformAssetMaintenances (Collection $assetmaintenances, $total)
|
|
{
|
|
$array = array();
|
|
foreach ($assetmaintenances as $assetmaintenance) {
|
|
$array[] = self::transformAssetMaintenance($assetmaintenance);
|
|
}
|
|
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
|
}
|
|
|
|
public function transformAssetMaintenance (AssetMaintenance $assetmaintenance)
|
|
{
|
|
$array = [
|
|
'id' => (int) $assetmaintenance->id,
|
|
'asset' => ($assetmaintenance->asset) ? [
|
|
'id' => (int) $assetmaintenance->asset->id,
|
|
'name'=> ($assetmaintenance->asset->name) ? e($assetmaintenance->asset->name) : null,
|
|
'asset_tag'=> e($assetmaintenance->asset->asset_tag)
|
|
|
|
] : null,
|
|
'model' => (($assetmaintenance->asset) && ($assetmaintenance->asset->model)) ? [
|
|
'id' => (int) $assetmaintenance->asset->model->id,
|
|
'name'=> ($assetmaintenance->asset->model->name) ? e($assetmaintenance->asset->model->name).' '.e($assetmaintenance->asset->model->model_number) : null
|
|
] : null,
|
|
'company' => (($assetmaintenance->asset) && ($assetmaintenance->asset->company)) ? [
|
|
'id' => (int) $assetmaintenance->asset->company->id,
|
|
'name'=> ($assetmaintenance->asset->company->name) ? e($assetmaintenance->asset->company->name) : null,
|
|
|
|
] : null,
|
|
'title' => ($assetmaintenance->title) ? e($assetmaintenance->title) : null,
|
|
'location' => (($assetmaintenance->asset) && ($assetmaintenance->asset->location)) ? [
|
|
'id' => (int) $assetmaintenance->asset->location->id,
|
|
'name'=> e($assetmaintenance->asset->location->name),
|
|
|
|
] : null,
|
|
'notes' => ($assetmaintenance->notes) ? e($assetmaintenance->notes) : null,
|
|
'supplier' => ($assetmaintenance->supplier) ? ['id' => $assetmaintenance->supplier->id,'name'=> e($assetmaintenance->supplier->name)] : null,
|
|
'cost' => Helper::formatCurrencyOutput($assetmaintenance->cost),
|
|
'asset_maintenance_type' => e($assetmaintenance->asset_maintenance_type),
|
|
'start_date' => Helper::getFormattedDateObject($assetmaintenance->start_date, 'date'),
|
|
'asset_maintenance_time' => $assetmaintenance->asset_maintenance_time,
|
|
'completion_date' => Helper::getFormattedDateObject($assetmaintenance->completion_date, 'date'),
|
|
'user_id' => ($assetmaintenance->admin) ? ['id' => $assetmaintenance->admin->id,'name'=> e($assetmaintenance->admin->getFullNameAttribute())] : null,
|
|
'created_at' => Helper::getFormattedDateObject($assetmaintenance->created_at, 'datetime'),
|
|
'updated_at' => Helper::getFormattedDateObject($assetmaintenance->updated_at, 'datetime'),
|
|
|
|
];
|
|
|
|
$permissions_array['available_actions'] = [
|
|
'update' => (bool) Gate::allows('update', Asset::class),
|
|
'delete' => (bool) Gate::allows('delete', Asset::class),
|
|
];
|
|
|
|
$array += $permissions_array;
|
|
|
|
return $array;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|