mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
33 lines
1002 B
PHP
33 lines
1002 B
PHP
<?php
|
|
|
|
namespace Crater\Http\Resources\Customer;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class TransactionResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'transaction_id' => $this->transaction_id,
|
|
'type' => $this->type,
|
|
'status' => $this->status,
|
|
'transaction_date' => $this->transaction_date,
|
|
'invoice_id' => $this->invoice_id,
|
|
'invoice' => $this->when($this->invoice()->exists(), function () {
|
|
return new InvoiceResource($this->invoice);
|
|
}),
|
|
'company' => $this->when($this->company()->exists(), function () {
|
|
return new CompanyResource($this->company);
|
|
}),
|
|
];
|
|
}
|
|
}
|