36 lines
934 B
PHP
36 lines
934 B
PHP
<?php
|
|
|
|
namespace App\Resources;
|
|
|
|
use App\Enumerations\EatingHabit;
|
|
use App\Enumerations\EfzStatus;
|
|
use App\Enumerations\ParticipationType;
|
|
use App\Models\CostUnitEstimate;
|
|
use App\Models\EventParticipant;
|
|
use App\ValueObjects\Age;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class CostUnitEstimateResource extends JsonResource
|
|
{
|
|
function __construct(CostUnitEstimate $estimate)
|
|
{
|
|
parent::__construct($estimate);
|
|
}
|
|
|
|
public function toArray($request) : array
|
|
{
|
|
$amountString = $this->resource->flat_amount?->toString();
|
|
if ($amountString === null) {
|
|
$amountString = $this->resource->amount_by_user?->toString() . ' / Person';
|
|
} else {
|
|
$amountString .= ' Gesamt';
|
|
}
|
|
|
|
return [
|
|
'id' => $this->resource->id,
|
|
'title' => $this->resource->description,
|
|
'totalAmountString' => $amountString,
|
|
];
|
|
}
|
|
}
|