generated from liutk/owl-admin-base
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Http\Response;
|
|
|
|
class UserGiftResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'gift_name'=>$this->whenLoaded('gift', function () {
|
|
return $this->gift->name;
|
|
}, ''),
|
|
'gift_logo'=> $this->whenLoaded('gift', function () {
|
|
return $this->gift->logo;
|
|
}, ''),
|
|
'gift_rank'=> $this->whenLoaded('gift', function () {
|
|
return $this->gift->rank;
|
|
}, ''),
|
|
'gift_explain'=> $this->whenLoaded('gift', function () {
|
|
return nl2br($this->gift->explain);
|
|
}, ''),
|
|
'activity_name' => $this->whenLoaded('activity', function () {
|
|
return $this->activity->name;
|
|
}, ''),
|
|
|
|
'consignee' => $this->consignee ?? '',
|
|
'address' => $this->address ?? '',
|
|
'phone' => $this->phone ?? '',
|
|
'shipping_company' => $this->shipping_company ?? '',
|
|
'shipping_number' => $this->shipping_number ?? '',
|
|
|
|
'state' => $this->state,
|
|
];
|
|
}
|
|
|
|
public function with($request)
|
|
{
|
|
return ['code' => Response::HTTP_OK, 'message' => ''];
|
|
}
|
|
} |