mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
c2616412c0
* Add laravel routes to javascript This will clean up a lot of passing of urls. Adds a route() helper and everything... This commit also moves the customfield fetching to only be fetched once and shared with each file, rather than once for each file. * Try to fix travis unit test things. * Downgrade doctrine/inflector for php5 * Attempt to occasional seeder issues on travis if the asset does not generate validatable data. * Update sql dump for functional tests. * Try to fix api tests.
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
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' => (int) $import->id,
|
|
'file_path' => e($import->file_path),
|
|
'filesize' => Setting::fileSizeConvert($import->filesize),
|
|
'name' => e($import->name),
|
|
'import_type' => e($import->import_type),
|
|
'created_at' => $import->created_at->diffForHumans(),
|
|
'header_row' => $import->header_row,
|
|
'first_row' => $import->first_row,
|
|
'field_map' => $import->field_map,
|
|
];
|
|
|
|
return $array;
|
|
}
|
|
|
|
public function transformImportsDatatable($imports)
|
|
{
|
|
return (new DatatablesTransformer)->transformDatatables($imports);
|
|
}
|
|
}
|