Implemented Event Budget

This commit is contained in:
2026-05-26 18:12:42 +02:00
parent 575fb27018
commit 28ffbdb696
17 changed files with 422 additions and 143 deletions
+15 -5
View File
@@ -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,
];
}
}