Implemented Event Budget
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Enumerations\ParticipationType;
|
||||
use App\Models\CostUnitEstimate;
|
||||
use App\Models\EventParticipant;
|
||||
use App\ValueObjects\Age;
|
||||
use App\ValueObjects\Amount;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CostUnitEstimateResource extends JsonResource
|
||||
@@ -19,17 +20,26 @@ class CostUnitEstimateResource extends JsonResource
|
||||
|
||||
public function toArray($request) : array
|
||||
{
|
||||
$amountString = $this->resource->flat_amount?->toString();
|
||||
if ($amountString === null) {
|
||||
$amountString = $this->resource->amount_by_user?->toString() . ' / Person';
|
||||
$amount = $this->resource->calculateAmount();
|
||||
$singleAmountString = $this->resource->flat_amount?->toString();
|
||||
$amountType = 'flat';
|
||||
if ($singleAmountString === null) {
|
||||
$amountType = 'per_person';
|
||||
$singleAmountString = $this->resource->amount_by_user->toString() . ' / Person (' . $amount->toString() . ' Gesamt)';
|
||||
} else {
|
||||
$amountString .= ' Gesamt';
|
||||
$singleAmountString .= ' Gesamt';
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->resource->id,
|
||||
'title' => $this->resource->description,
|
||||
'totalAmountString' => $amountString,
|
||||
'singleAmountString' => $singleAmountString,
|
||||
'calculatedAmount' => $amount,
|
||||
'calculatedAmountString' => $amount->toString(),
|
||||
'amountValue' => $amount->getAmount(),
|
||||
'amountType' => $amountType,
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user