More custom date display via API

This commit is contained in:
snipe 2017-03-03 17:53:42 -08:00
parent 4f1669189e
commit 097096aa24
9 changed files with 28 additions and 17 deletions

View file

@ -4,6 +4,7 @@ namespace App\Http\Transformers;
use App\Models\Accessory;
use Gate;
use Illuminate\Database\Eloquent\Collection;
use App\Helpers\Helper;
class AccessoriesTransformer
{
@ -34,6 +35,8 @@ class AccessoriesTransformer
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
'min_qty' => ($accessory->min_amt) ? e($accessory->min_amt) : null,
'remaining_qty' => $accessory->numRemaining(),
'created_at' => Helper::getFormattedDateObject($accessory->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($accessory->updated_at, 'datetime'),
];

View file

@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Collection;
use App\Http\Transformers\UsersTransformer;
use Gate;
use App\Helpers\Helper;
use App\Models\Setting;
class AssetsTransformer
@ -24,7 +23,7 @@ class AssetsTransformer
public function transformAsset (Asset $asset)
{
$settings = Setting::getSettings();
$array = [
'id' => $asset->id,
'name' => e($asset->name),

View file

@ -38,7 +38,7 @@ class ComponentsTransformer
'name' => e($component->category->name)
] : null,
'order_number' => e($component->order_number),
'purchase_date' => $component->purchase_date,
'purchase_date' => Helper::getFormattedDateObject($component->purchase_date, 'date'),
'purchase_cost' => Helper::formatCurrencyOutput($component->purchase_cost),
'remaining' => $component->numRemaining(),
'company' => ($component->company) ?
@ -46,6 +46,8 @@ class ComponentsTransformer
'id' => $component->company->id,
'name' => e($component->company->name)
] : null,
'created_at' => Helper::getFormattedDateObject($component->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($component->updated_at, 'datetime'),
];

View file

@ -33,8 +33,10 @@ class ConsumablesTransformer
'remaining' => $consumable->numRemaining(),
'order_number' => $consumable->order_number,
'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost),
'purchase_date' => $consumable->purchase_date,
'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'),
'qty' => $consumable->qty,
'created_at' => Helper::getFormattedDateObject($consumable->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'),
];
$permissions_array['available_actions'] = [

View file

@ -24,6 +24,8 @@ class GroupsTransformer
'name' => e($group->name),
'permissions' => $group->permissions,
'users_count' => $group->users_count,
'created_at' => Helper::getFormattedDateObject($group->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($group->updated_at, 'datetime'),
];
$permissions_array['available_actions'] = [

View file

@ -28,11 +28,11 @@ class LicensesTransformer
'product_key' => e($license->serial),
'order_number' => e($license->order_number),
'purchase_order' => e($license->purchase_order),
'purchase_date' => e($license->purchase_date),
'purchase_date' => Helper::getFormattedDateObject($license->purchase_date, 'date'),
'purchase_cost' => e($license->purchase_cost),
'depreciation' => ($license->depreciation) ? ['id' => $license->depreciation->id,'name'=> e($license->depreciation->name)] : null,
'notes' => e($license->notes),
'expiration_date' => e($license->expiration_date),
'expiration_date' => Helper::getFormattedDateObject($license->expiration_date, 'date'),
'total_seats' => e($license->seats),
'remaining_qty' => $license->remaincount(),
'min_qty' => $license->remaincount(),
@ -40,7 +40,8 @@ class LicensesTransformer
'license_email' => e($license->license_email),
'maintained' => ($license->maintained == 1) ? true : false,
'supplier' => ($license->supplier) ? ['id' => $license->supplier->id,'name'=> e($license->supplier->name)] : null,
'created_at' => $license->created_at,
'created_at' => Helper::getFormattedDateObject($license->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($license->updated_at, 'datetime'),
];
$permissions_array['available_actions'] = [

View file

@ -4,6 +4,7 @@ namespace App\Http\Transformers;
use App\Models\Statuslabel;
use Illuminate\Database\Eloquent\Collection;
use Gate;
use App\Helpers\Helper;
class StatuslabelsTransformer
{
@ -26,8 +27,8 @@ class StatuslabelsTransformer
'color' => ($statuslabel->color) ? e($statuslabel->color) : null,
'show_in_nav' => ($statuslabel->show_in_nav=='1') ? true : false,
'notes' => e($statuslabel->notes),
'created_at' => $statuslabel->created_at,
'updated_at' => $statuslabel->updated_at,
'created_at' => Helper::getFormattedDateObject($statuslabel->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($statuslabel->updated_at, 'datetime'),
];
$permissions_array['available_actions'] = [

View file

@ -5,6 +5,7 @@ use App\Models\User;
use Illuminate\Database\Eloquent\Collection;
use phpDocumentor\Reflection\Types\Integer;
use Gate;
use App\Helpers\Helper;
class UsersTransformer
{
@ -35,19 +36,20 @@ class UsersTransformer
'permissions' => $user->decodePermissions(),
'activated' => ($user->activated =='1') ? true : false,
'two_factor_activated' => ($user->activated =='1') ? true : false,
'created_at' => $user->created_at,
'updated_at' => $user->updated_at,
'assets_count' => $user->assets_count,
'licenses_count' => $user->licenses_count,
'accessories_count' => $user->accessories_count,
'consumables_count' => $user->consumables_count,
'company' => ($user->company) ? ['id' => $user->company->id,'name'=> e($user->company->name)] : null,
'created_at' => Helper::getFormattedDateObject($user->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($user->updated_at, 'datetime'),
];
$permissions_array['available_actions'] = [
'edit' => Gate::allows('edit', User::class) ? true : false,
'update' => Gate::allows('update', User::class) ? true : false,
'delete' => Gate::allows('delete', User::class) ? true : false,
];
$array += $permissions_array;
return $array;

View file

@ -28,12 +28,11 @@ class UserPresenter extends Presenter
],
[
"field" => "id",
"searchable" => true,
"searchable" => false,
"sortable" => true,
"switchable" => false,
"switchable" => true,
"title" => trans('general.id'),
"visible" => false,
"formatter" => null
"visible" => false
],
[
"field" => "company",
@ -175,7 +174,7 @@ class UserPresenter extends Presenter
"switchable" => true,
"title" => trans('general.created_at'),
"visible" => false,
'formatter' => 'createdAtFormatter'
'formatter' => 'dateDisplayFormatter'
],
[
"field" => "actions",