WIP
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\DTO;
|
||||
|
||||
use sammo\Json;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
use Spatie\DataTransferObject\Attributes\MapFrom;
|
||||
use Spatie\DataTransferObject\Attributes\MapTo;
|
||||
|
||||
class AuctionBidItem extends DataTransferObject{
|
||||
public int $id;
|
||||
#[MapFrom('auction_id')]
|
||||
#[MapTo('auction_id')]
|
||||
public int $auctionID;
|
||||
public ?int $owner;
|
||||
|
||||
#[MapFrom('general_id')]
|
||||
#[MapTo('general_id')]
|
||||
public int $generalID;
|
||||
|
||||
public int $amount;
|
||||
|
||||
public string $date;
|
||||
public AuctionBidItemData $data;
|
||||
|
||||
public static function parse(array $data): self
|
||||
{
|
||||
$data['data'] = Json::decode($data['data']);
|
||||
return new self($data);
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$result = parent::toArray();
|
||||
$result['data'] = Json::encode($this->data);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user