mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-27 14:39:49 -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
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
namespace App\Http\Transformers;
|
|
|
|
use App\Models\Company;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Gate;
|
|
use App\Helpers\Helper;
|
|
|
|
class CompaniesTransformer
|
|
{
|
|
|
|
public function transformCompanies (Collection $companies, $total)
|
|
{
|
|
$array = array();
|
|
foreach ($companies as $company) {
|
|
$array[] = self::transformCompany($company);
|
|
}
|
|
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
|
}
|
|
|
|
public function transformCompany (Company $company = null)
|
|
{
|
|
if ($company) {
|
|
|
|
$array = [
|
|
'id' => (int) $company->id,
|
|
'name' => e($company->name),
|
|
'image' => ($company->image) ? e(url('/').'/uploads/companies/'.e($company->image)) : null,
|
|
"created_at" => Helper::getFormattedDateObject($company->created_at, 'datetime'),
|
|
"updated_at" => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
|
|
"assets_count" => (int) $company->assets_count,
|
|
"licenses_count" => (int) $company->licenses_count,
|
|
"accessories_count" => (int) $company->accessories_count,
|
|
"consumables_count" => (int) $company->consumables_count,
|
|
"components_count" => (int) $company->components_count,
|
|
"users_count" => (int) $company->users_count
|
|
];
|
|
|
|
$permissions_array['available_actions'] = [
|
|
'update' => Gate::allows('update', Company::class) ? true : false,
|
|
'delete' => Gate::allows('delete', Company::class) ? true : false,
|
|
];
|
|
|
|
$array += $permissions_array;
|
|
|
|
return $array;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|