Updated Giveaway
This commit is contained in:
parent
c22ef6e2ff
commit
0a411cec79
1 changed files with 8 additions and 4 deletions
|
@ -121,7 +121,7 @@ class Giveaway implements ObjectTypeInterface
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'chats' => array_map(fn(Chat $chat) => $chat->toArray(), $this->chats),
|
'chats' => is_null($this->chats) ? null : array_map(fn(Chat $chat) => $chat->toArray(), $this->chats),
|
||||||
'winners_selection_date' => $this->winners_selection_date,
|
'winners_selection_date' => $this->winners_selection_date,
|
||||||
'winner_count' => $this->winner_count,
|
'winner_count' => $this->winner_count,
|
||||||
'only_new_members' => $this->only_new_members,
|
'only_new_members' => $this->only_new_members,
|
||||||
|
@ -136,11 +136,15 @@ class Giveaway implements ObjectTypeInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): ObjectTypeInterface
|
public static function fromArray(?array $data): ?Giveaway
|
||||||
{
|
{
|
||||||
$object = new self();
|
if($data === null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$object->chats = array_map(fn(array $chat) => Chat::fromArray($chat), $data['chats']);
|
$object = new self();
|
||||||
|
$object->chats = isset($data['chats']) ? array_map(fn(array $chat) => Chat::fromArray($chat), $data['chats']) : null;
|
||||||
$object->winners_selection_date = $data['winners_selection_date'];
|
$object->winners_selection_date = $data['winners_selection_date'];
|
||||||
$object->winner_count = $data['winner_count'];
|
$object->winner_count = $data['winner_count'];
|
||||||
$object->only_new_members = $data['only_new_members'] ?? false;
|
$object->only_new_members = $data['only_new_members'] ?? false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue