Added additional permissions for checkin/checkout buttons
This commit is contained in:
@@ -42,11 +42,17 @@ class AccessoriesTransformer
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'checkout' => Gate::allows('checkout', Accessory::class) ? true : false,
|
||||
'checkin' => Gate::allows('checkin', Accessory::class) ? true : false,
|
||||
'checkin' => false,
|
||||
'update' => Gate::allows('update', Accessory::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', Accessory::class) ? true : false,
|
||||
];
|
||||
|
||||
$permissions_array['user_can_checkout'] = false;
|
||||
|
||||
if ($accessory->numRemaining() > 0) {
|
||||
$permissions_array['user_can_checkout'] = true;
|
||||
}
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
return $array;
|
||||
|
||||
@@ -49,7 +49,7 @@ class AssetsTransformer
|
||||
'last_checkout' => Helper::getFormattedDateObject($asset->last_checkout, 'datetime'),
|
||||
'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'date'),
|
||||
'purchase_cost' => $asset->purchase_cost,
|
||||
'can_checkout' => $asset->availableForCheckout(),
|
||||
'user_can_checkout' => $asset->availableForCheckout(),
|
||||
|
||||
];
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class ComponentsAssetsTransformer
|
||||
'name' => e($asset->name),
|
||||
'created_at' => $asset->created_at->format('Y-m-d'),
|
||||
'qty' => $asset->components()->count(),
|
||||
'can_checkout' => $asset->availableForCheckout(),
|
||||
'user_can_checkout' => $asset->availableForCheckout(),
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
@@ -36,6 +36,8 @@ class ComponentsAssetsTransformer
|
||||
'delete' => Gate::allows('delete', Asset::class) ? true : false,
|
||||
];
|
||||
|
||||
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
if ($asset->model->fieldset) {
|
||||
|
||||
@@ -39,6 +39,12 @@ class ConsumablesTransformer
|
||||
'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'),
|
||||
];
|
||||
|
||||
$permissions_array['user_can_checkout'] = false;
|
||||
|
||||
if ($consumable->numRemaining() > 0) {
|
||||
$permissions_array['user_can_checkout'] = true;
|
||||
}
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'checkout' => Gate::allows('checkout', Consumable::class) ? true : false,
|
||||
'checkin' => Gate::allows('checkin', Consumable::class) ? true : false,
|
||||
|
||||
Reference in New Issue
Block a user