mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
934afa036f
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
42 lines
1 KiB
PHP
42 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Transformers;
|
|
|
|
use App\Models\Import;
|
|
use App\Models\Setting;
|
|
|
|
class ImportsTransformer
|
|
{
|
|
public function transformImports($imports)
|
|
{
|
|
$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);
|
|
}
|
|
}
|