香洲二院小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
mini_xzey/app/Http/Resources/Dictionary/ItemDetailsResource.php

35 lines
853 B

<?php
namespace App\Http\Resources\Dictionary;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ItemDetailsResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request = null): array
{
if (empty($this->resource)) {
return [];
}
$lists = [];
foreach ($this->resource['response'] as $v) {
$lists[] = [
'type_name' => $v['typeName'],
'item_name' => $v['costName'],
'unit' => $v['unit'],
'spec' => $v['costSpec'],
'price' => (float) $v['price'],
'cd_name' => $v['manufacturer'] ?? '',
];
}
return $lists;
}
}