27 lines
767 B
PHP
27 lines
767 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api\Admin;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class OrderResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'order_num' => $this->order_num,
|
|
'customer' => $this->whenLoaded('customer', fn() => [
|
|
'id' => $this->customer->id,
|
|
'fullname' => $this->customer->fullname,
|
|
'email' => $this->customer->email,
|
|
]),
|
|
'amount' => $this->amount,
|
|
'status' => $this->status,
|
|
'date' => $this->date,
|
|
'created_at' => $this->created_at,
|
|
];
|
|
}
|
|
}
|