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.
29 lines
646 B
29 lines
646 B
<?php
|
|
|
|
namespace App\Http\Resources\API\v2;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class CartResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
$city_name = $this->city->name;
|
|
$company_name = $this->company->name;
|
|
$items = $this->items;
|
|
|
|
return [
|
|
'id' => $this->id,
|
|
'cityName' => $city_name,
|
|
'companyName' => $company_name,
|
|
'item' => new ItemCollection($items),
|
|
];
|
|
}
|
|
}
|