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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\DTO;
|
||||
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
|
||||
class AuctionBidItemData extends DataTransferObject{
|
||||
public string $ownerName;
|
||||
public string $generalName;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\DTO;
|
||||
|
||||
use Spatie\DataTransferObject\Attributes\CastWith;
|
||||
use Spatie\DataTransferObject\Attributes\Strict;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
|
||||
use sammo\Enums\ResourceType;
|
||||
use sammo\DTO\Caster\BackedEnumCaster;
|
||||
|
||||
//https://json2dto.atymic.dev/
|
||||
|
||||
|
||||
|
||||
#[Strict]
|
||||
class AuctionInfo extends DataTransferObject
|
||||
{
|
||||
public int $id;
|
||||
public int $openerName;
|
||||
public int $openerGeneralID;
|
||||
public string $type;
|
||||
public bool $finished;
|
||||
#[CastWith(BackedEnumCaster::class)]
|
||||
public ResourceType $reqResource;
|
||||
public string $openDate;
|
||||
public string $closeDate;
|
||||
}
|
||||
Reference in New Issue
Block a user