mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 14:09:43 -08:00
40 lines
945 B
PHP
40 lines
945 B
PHP
|
<?php
|
||
|
namespace App\Http\Transformers;
|
||
|
|
||
|
use App\Models\Import;
|
||
|
use App\Models\Setting;
|
||
|
use Illuminate\Database\Eloquent\Collection;
|
||
|
|
||
|
class ImportsTransformer
|
||
|
{
|
||
|
|
||
|
public function transformImports($imports)
|
||
|
{
|
||
|
$array = array();
|
||
|
foreach ($imports as $import) {
|
||
|
$array[] = self::transformImport($import);
|
||
|
}
|
||
|
return $array;
|
||
|
}
|
||
|
|
||
|
public function transformImport(Import $import)
|
||
|
{
|
||
|
$array = [
|
||
|
'id' => $import->id,
|
||
|
'file_path' => $import->file_path,
|
||
|
'filesize' => Setting::fileSizeConvert($import->filesize),
|
||
|
'name' => $import->name,
|
||
|
'import_type' => $import->import_type,
|
||
|
'created_at' => $import->created_at->diffForHumans(),
|
||
|
|
||
|
];
|
||
|
|
||
|
return $array;
|
||
|
}
|
||
|
|
||
|
public function transformImportsDatatable($imports)
|
||
|
{
|
||
|
return (new DatatablesTransformer)->transformDatatables($imports);
|
||
|
}
|
||
|
}
|