createdAt = new \DateTimeImmutable('now'); $this->salesPrice = new FloatInt(); $this->purchasePrice = new FloatInt(); } /** * Add item l11n * * @param BaseStringL11n $l11n Item localization * * @return void * * @since 1.0.0 */ public function addL11n(BaseStringL11n $l11n) : void { foreach ($this->l11n as $l11n) { if ($l11n->type?->title === $l11n->type?->title) { return; } } $this->l11n[] = $l11n; } /** * Get l11n * * @param null|string $type Localization type * * @return BaseStringL11n * * @since 1.0.0 */ public function getL11n(?string $type = null) : BaseStringL11n { foreach ($this->l11n as $l11n) { if ($l11n->type?->title === $type) { return $l11n; } } return new NullBaseStringL11n(); } /** * Get localizations * * @return BaseStringL11n[] * * @since 1.0.0 */ public function getL11ns() : array { return $this->l11n; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'number' => $this->number, 'status' => $this->status, 'info' => $this->info, 'l11n' => $this->l11n, ]; } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } use \Modules\Media\Models\MediaListTrait; use \Modules\Editor\Models\EditorDocListTrait; use \Modules\Attribute\Models\AttributeHolderTrait; }