35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Http\Response;
|
|
|
|
class UserTicketResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'ticket_name' => $this->quanTicket->quan_name,
|
|
'ticket_value' => number_format($this->quanTicket->ticket_value, 0),
|
|
'desc' => $this->quanTicket->use_rule??'',
|
|
'use_limit' => '满'.number_format($this->quanTicket->use_limit, 0).'元可用',
|
|
'ticket_status' => ($this->ticket_status == 0 ) ? ($this->end_time <= Carbon::now() ? '1':'0'):'2',
|
|
'end_time' => Carbon::parse($this->end_time)->format('Y.m.d H:i'),
|
|
// 'created_at'=> $this->created_at->format('Y.m.d H:i')
|
|
];
|
|
}
|
|
|
|
public function with($request)
|
|
{
|
|
return ['code' => Response::HTTP_OK, 'message' => ''];
|
|
}
|
|
} |