29 lines
823 B
PHP
29 lines
823 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Resources;
|
||
|
|
|
||
|
|
use App\Models\InstantWin;
|
||
|
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||
|
|
|
||
|
|
class InstantWinResource extends ResourceCollection
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Transform the resource into an array.
|
||
|
|
*
|
||
|
|
* @param mixed $request
|
||
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||
|
|
*/
|
||
|
|
public function toArray($request)
|
||
|
|
{
|
||
|
|
return $this->collection->map(function (InstantWin $instantWin) {
|
||
|
|
return [
|
||
|
|
'id' => $instantWin->id,
|
||
|
|
'won' => $instantWin->won,
|
||
|
|
'appear_date' => $instantWin->appear_date->format('Y-m-d H:i'),
|
||
|
|
'prize' => $instantWin->prize
|
||
|
|
];
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|