1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Waredesk\Models; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
use Waredesk\Collections\Products\Variants; |
7
|
|
|
use JsonSerializable; |
8
|
|
|
|
9
|
|
|
class Product implements JsonSerializable |
10
|
|
|
{ |
11
|
|
|
private $id; |
12
|
|
|
private $images; |
13
|
|
|
private $variants; |
14
|
|
|
private $name; |
15
|
|
|
private $description; |
16
|
|
|
private $notes; |
17
|
|
|
private $creation_datetime; |
18
|
|
|
private $modification_datetime; |
19
|
|
|
|
20
|
|
|
public function __construct() |
21
|
|
|
{ |
22
|
|
|
$this->variants = new Variants(); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function getId(): ?int |
26
|
|
|
{ |
27
|
|
|
return $this->id; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function setId(int $id = null) |
31
|
|
|
{ |
32
|
|
|
$this->id = $id; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getImages(): ?array |
36
|
|
|
{ |
37
|
|
|
return $this->images; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function setImages(array $images = null) |
41
|
|
|
{ |
42
|
|
|
$this->images = $images; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getVariants(): ?Variants |
46
|
|
|
{ |
47
|
|
|
return $this->variants; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function setVariants(Variants $variants) |
51
|
|
|
{ |
52
|
|
|
$this->variants = $variants; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getName(): ?string |
56
|
|
|
{ |
57
|
|
|
return $this->name; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setName(string $name = null) |
61
|
|
|
{ |
62
|
|
|
$this->name = $name; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getDescription(): ?string |
66
|
|
|
{ |
67
|
|
|
return $this->description; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setDescription(string $description = null) |
71
|
|
|
{ |
72
|
|
|
$this->description = $description; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getNotes(): ?string |
76
|
|
|
{ |
77
|
|
|
return $this->notes; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function setNotes(string $notes = null) |
81
|
|
|
{ |
82
|
|
|
$this->notes = $notes; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getCreationDatetime(): ?DateTime |
86
|
|
|
{ |
87
|
|
|
return $this->creation_datetime; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function setCreationDatetime(DateTime $creation_datetime = null) |
91
|
|
|
{ |
92
|
|
|
$this->creation_datetime = $creation_datetime; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getModificationDatetime(): ?DateTime |
96
|
|
|
{ |
97
|
|
|
return $this->modification_datetime; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function setModificationDatetime(DateTime $modification_datetime = null) |
101
|
|
|
{ |
102
|
|
|
$this->modification_datetime = $modification_datetime; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function jsonSerialize() |
106
|
|
|
{ |
107
|
|
|
$returnValue = [ |
108
|
|
|
'variants' => $this->getVariants()->jsonSerialize(), |
109
|
|
|
'name' => $this->getName(), |
|
|
|
|
110
|
|
|
'description' => $this->getDescription(), |
111
|
|
|
'notes' => $this->getNotes(), |
112
|
|
|
]; |
113
|
|
|
//if ($this->getImages() instanceof NewImage) { |
|
|
|
|
114
|
|
|
// $returnValue['image'] = base64($this->getNewImage()); |
|
|
|
|
115
|
|
|
// } |
116
|
|
|
return $returnValue; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|