adrema/app/Invoice/Resources/InvoicePositionResource.php

32 lines
776 B
PHP
Raw Permalink Normal View History

2023-12-17 00:45:03 +01:00
<?php
namespace App\Invoice\Resources;
use App\Invoice\Models\InvoicePosition;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin InvoicePosition
*/
class InvoicePositionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array<string, mixed>
*/
public function toArray($request)
{
return [
'id' => $this->id,
'price' => $this->price,
'member_id' => $this->member_id,
'description' => $this->description,
2023-12-17 21:13:52 +01:00
'invoice' => new InvoiceResource($this->whenLoaded('invoice')),
'price_human' => number_format($this->price / 100, 2, ',', '') . ' €',
2023-12-17 00:45:03 +01:00
];
}
}