mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
namespace App\Http\Transformers;
|
|
|
|
use App\Models\Depreciation;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Gate;
|
|
use App\Helpers\Helper;
|
|
|
|
class DepreciationsTransformer
|
|
{
|
|
|
|
public function transformDepreciations (Collection $depreciations)
|
|
{
|
|
$array = array();
|
|
foreach ($depreciations as $depreciation) {
|
|
$array[] = self::transformDepreciation($depreciation);
|
|
}
|
|
return (new DatatablesTransformer)->transformDatatables($array);
|
|
}
|
|
|
|
public function transformDepreciation (Depreciation $depreciation)
|
|
{
|
|
$array = [
|
|
'id' => (int) $depreciation->id,
|
|
'name' => e($depreciation->name),
|
|
'months' => $depreciation->months . ' '. trans('general.months'),
|
|
'created_at' => Helper::getFormattedDateObject($depreciation->created_at, 'datetime'),
|
|
'updated_at' => Helper::getFormattedDateObject($depreciation->updated_at, 'datetime'),
|
|
];
|
|
|
|
$permissions_array['available_actions'] = [
|
|
'update' => Gate::allows('update', Depreciation::class) ? true : false,
|
|
'delete' => Gate::allows('delete', Depreciation::class) ? true : false,
|
|
];
|
|
|
|
$array += $permissions_array;
|
|
|
|
return $array;
|
|
}
|
|
|
|
|
|
|
|
}
|