mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 23:54:12 -08:00
75b527ab59
* Locations API support for image * Added manufacturers API support for image * Added manufacturers API support for image * Added image support for locations add/update * Added manufacturer image upload support to controller * General image string * Added blade support for image uploads/delete image * Added $request support (from Input::) * Added image support in API transformers * Added image to Manufacturers presenter for data table * Migration to create image fields * Ignore the contents of the new image directories * Create new image upload directories * Created components/consumables uploads directory * Fixed missing textSearch scope from companies * Added ignore for companies uploads directory * Added blade support for image upload * Fixed path to upload directory on edit * Added company image upport to transformers, controllers * Added image support for categories * Added support for images in Departments * Added support for image in Consumables * Added image support for components
57 lines
1.9 KiB
PHP
57 lines
1.9 KiB
PHP
<?php
|
|
namespace App\Http\Transformers;
|
|
|
|
use App\Models\Manufacturer;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Gate;
|
|
use App\Helpers\Helper;
|
|
|
|
class ManufacturersTransformer
|
|
{
|
|
|
|
public function transformManufacturers (Collection $manufacturers, $total)
|
|
{
|
|
$array = array();
|
|
foreach ($manufacturers as $manufacturer) {
|
|
$array[] = self::transformManufacturer($manufacturer);
|
|
}
|
|
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
|
}
|
|
|
|
public function transformManufacturer (Manufacturer $manufacturer = null)
|
|
{
|
|
if ($manufacturer) {
|
|
|
|
$array = [
|
|
'id' => (int) $manufacturer->id,
|
|
'name' => e($manufacturer->name),
|
|
'url' => e($manufacturer->url),
|
|
'image' => ($manufacturer->image) ? e(url('/').'/uploads/manufacturers/'.e($manufacturer->image)) : null,
|
|
'support_url' => e($manufacturer->support_url),
|
|
'support_phone' => e($manufacturer->support_phone),
|
|
'support_email' => e($manufacturer->support_email),
|
|
'assets_count' => (int) $manufacturer->assets_count,
|
|
'licenses_count' => (int) $manufacturer->licenses_count,
|
|
'consumables_count' => (int) $manufacturer->consumables_count,
|
|
'accessories_count' => (int) $manufacturer->accessories_count,
|
|
'created_at' => Helper::getFormattedDateObject($manufacturer->created_at, 'datetime'),
|
|
'updated_at' => Helper::getFormattedDateObject($manufacturer->updated_at, 'datetime'),
|
|
];
|
|
|
|
$permissions_array['available_actions'] = [
|
|
'update' => Gate::allows('update', Manufacturer::class) ? true : false,
|
|
'delete' => Gate::allows('delete', Manufacturer::class) ? true : false,
|
|
];
|
|
|
|
$array += $permissions_array;
|
|
|
|
return $array;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|