buckets/app/Http/Resources/BucketResource.php

30 lines
1 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class BucketResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->uuid,
'name' => $this->name,
'type' => $this->type,
'type_label' => $this->type->getLabel(),
'priority' => $this->priority,
'sort_order' => $this->sort_order,
'allocation_type' => $this->allocation_type,
'allocation_value' => $this->allocation_value,
'allocation_type_label' => $this->getAllocationTypeLabel(),
'buffer_multiplier' => (float) $this->buffer_multiplier,
'effective_capacity' => $this->getEffectiveCapacity(),
'starting_amount' => $this->starting_amount,
'current_balance' => $this->getCurrentBalance(),
'has_available_space' => $this->hasAvailableSpace(),
'available_space' => $this->getAvailableSpace(),
];
}
}