6
0
Fork 0
jiqu-library-server/app/Endpoint/Api/Http/Resources/Dealer/UserProductResource.php

27 lines
739 B
PHP

<?php
namespace App\Endpoint\Api\Http\Resources\Dealer;
use Illuminate\Http\Resources\Json\JsonResource;
class UserProductResource 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 [
'product_id' => $this->product_id,
'name' => $this->product?->name,
'cover' => (string) $this->product?->cover,
'price' => (string) $this->product?->price,
'stock' => (int) $this->stock,
'deposit_stock'=> (int) $this->deposit_stock,
];
}
}