Gift
extends BaseEntity
in package
implements
IdentifiableInterface
uses
IdentifiableTrait, TranslationCollectionTrait
Gift: a free gift added to an order. It has two links to product sets: - `$productSet`: the gift is itself a sellable product set (nullable; the alternative is a purely named gift with an `$image`), - `$offerSets`: many-to-many, the gift is offered when buying the set (edited in the product set form).
Cart value thresholds per currency (GiftPrice) decide the offer; the Api
GiftManager::findOfferedForCart()/findForSets() assemble it.
A gift never enters total_price (it is free).
Tags
Attributes
- #[MappedSuperclass]
- #[TableAlias]
- $alias: 'gift'
Table of Contents
Interfaces
- IdentifiableInterface
- Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).
Properties
- $amount : int
- $available : bool
- $availableForOrder : bool
- $endDatetime : DateTime|null
- $hidden : bool
- $id : int|null
- $image : TImage|null
- $insertDatetime : DateTime|null
- $offerSets : Collection<int, TOfferSet>
- $prices : Collection<int, TPrice>
- $priority : int
- $productSet : TProductSet|null
- $startDatetime : DateTime|null
- $translations : Collection<int, TTranslation>
Methods
- __construct() : mixed
- addOfferSet() : $this
- addPrice() : $this
- addTranslation() : $this
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getAmount() : int
- getAvailable() : bool
- getAvailableForOrder() : bool
- getEndDatetime() : DateTime|null
- getHidden() : bool
- getId() : int|null
- getImage() : TImage|null
- getInsertDatetime() : DateTime|null
- getOfferSets() : Collection<int, TOfferSet>
- getPriceForCurrency() : TPrice|null
- Returns the gift's price/threshold row for the currency, or null when there is none.
- getPrices() : Collection<int, TPrice>
- getPriority() : int
- getProductSet() : TProductSet|null
- getStartDatetime() : DateTime|null
- getTranslation() : TTranslation|null
- getTranslations() : Collection<int, TTranslation>
- isAvailable() : bool
- isHidden() : bool
- isPersisted() : bool
- removeTranslation() : $this
- setAmount() : $this
- setAvailable() : $this
- setAvailableForOrder() : $this
- setEndDatetime() : $this
- setHidden() : $this
- setId() : $this
- setImage() : $this
- setInsertDatetime() : $this
- setOfferSets() : $this
- setPrices() : $this
- setPriority() : $this
- setProductSet() : $this
- setStartDatetime() : $this
- setTranslations() : $this
- translationCollectionInit() : void
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$amount
protected
int
$amount
= 1
Attributes
- #[Column]
- $name: 'amount'
- $type: 'integer'
- $options: ['unsigned' => true]
$available
protected
bool
$available
= true
Attributes
- #[Column]
- $name: 'available'
- $type: 'boolean'
$availableForOrder
protected
bool
$availableForOrder
= true
Attributes
- #[Column]
- $name: 'available_for_order'
- $type: 'boolean'
$endDatetime
protected
DateTime|null
$endDatetime
= null
Attributes
- #[Column]
- $name: 'end_datetime'
- $type: 'datetime'
- $nullable: true
$hidden
protected
bool
$hidden
= false
Attributes
- #[Column]
- $name: 'hidden'
- $type: 'boolean'
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $name: 'gift_id'
- $type: 'integer'
- $options: ['unsigned' => true]
- #[GeneratedValue]
- #[Id]
$image
protected
TImage|null
$image
= null
$insertDatetime
protected
DateTime|null
$insertDatetime
= null
Attributes
- #[Column]
- $name: 'insert_datetime'
- $type: 'datetime'
$offerSets
protected
Collection<int, TOfferSet>
$offerSets
= new ArrayCollection()
many-to-many: the product sets the gift is offered with
$prices
protected
Collection<int, TPrice>
$prices
= new ArrayCollection()
$priority
protected
int
$priority
= 0
Attributes
- #[Column]
- $name: 'priority'
- $type: 'integer'
$productSet
protected
TProductSet|null
$productSet
= null
the gift is this set (null = purely named gift)
$startDatetime
protected
DateTime|null
$startDatetime
= null
Attributes
- #[Column]
- $name: 'start_datetime'
- $type: 'datetime'
$translations
protected
Collection<int, TTranslation>
$translations
= new ArrayCollection()
Methods
__construct()
public
__construct([int|null $id = null ][, DateTime|null $startDatetime = null ][, DateTime|null $endDatetime = null ][, mixed $productSet = null ][, mixed $image = null ][, bool $available = true ][, bool $availableForOrder = true ][, bool $hidden = false ][, int $priority = 0 ][, int $amount = 1 ][, DateTime|null $insertDatetime = null ][, Collection $translations = new ArrayCollection() ][, Collection $prices = new ArrayCollection() ][, Collection $offerSets = new ArrayCollection() ]) : mixed
Parameters
- $id : int|null = null
- $startDatetime : DateTime|null = null
- $endDatetime : DateTime|null = null
- $productSet : mixed = null
- $image : mixed = null
- $available : bool = true
- $availableForOrder : bool = true
- $hidden : bool = false
- $priority : int = 0
- $amount : int = 1
- $insertDatetime : DateTime|null = null
- $translations : Collection = new ArrayCollection()
- $prices : Collection = new ArrayCollection()
- $offerSets : Collection = new ArrayCollection()
addOfferSet()
public
addOfferSet(TOfferSet $offerSet) : $this
Parameters
- $offerSet : TOfferSet
Return values
$thisaddPrice()
public
addPrice(TPrice $price) : $this
Parameters
- $price : TPrice
Return values
$thisaddTranslation()
public
addTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thiscallInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
getAllTraits()
Returns all traits the class uses, including those used by parent classes and nested traits.
public
getAllTraits() : array<string, string>
Return values
array<string, string>getAmount()
public
getAmount() : int
Return values
intgetAvailable()
public
getAvailable() : bool
Return values
boolgetAvailableForOrder()
public
getAvailableForOrder() : bool
Return values
boolgetEndDatetime()
public
getEndDatetime() : DateTime|null
Return values
DateTime|nullgetHidden()
public
getHidden() : bool
Return values
boolgetId()
public
getId() : int|null
Return values
int|nullgetImage()
public
getImage() : TImage|null
Return values
TImage|nullgetInsertDatetime()
public
getInsertDatetime() : DateTime|null
Return values
DateTime|nullgetOfferSets()
public
getOfferSets() : Collection<int, TOfferSet>
Return values
Collection<int, TOfferSet>getPriceForCurrency()
Returns the gift's price/threshold row for the currency, or null when there is none.
public
getPriceForCurrency(int $currencyId) : TPrice|null
Parameters
- $currencyId : int
Return values
TPrice|nullgetPrices()
public
getPrices() : Collection<int, TPrice>
Return values
Collection<int, TPrice>getPriority()
public
getPriority() : int
Return values
intgetProductSet()
public
getProductSet() : TProductSet|null
Return values
TProductSet|nullgetStartDatetime()
public
getStartDatetime() : DateTime|null
Return values
DateTime|nullgetTranslation()
public
getTranslation(int $langId) : TTranslation|null
Parameters
- $langId : int
Return values
TTranslation|nullgetTranslations()
public
getTranslations() : Collection<int, TTranslation>
Return values
Collection<int, TTranslation>isAvailable()
public
isAvailable() : bool
Return values
boolisHidden()
public
isHidden() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolremoveTranslation()
public
removeTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thissetAmount()
public
setAmount(int $amount) : $this
Parameters
- $amount : int
Return values
$thissetAvailable()
public
setAvailable(bool $available) : $this
Parameters
- $available : bool
Return values
$thissetAvailableForOrder()
public
setAvailableForOrder(bool $availableForOrder) : $this
Parameters
- $availableForOrder : bool
Return values
$thissetEndDatetime()
public
setEndDatetime(DateTime|null $endDatetime) : $this
Parameters
- $endDatetime : DateTime|null
Return values
$thissetHidden()
public
setHidden(bool $hidden) : $this
Parameters
- $hidden : bool
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetImage()
public
setImage(TImage|null $image) : $this
Parameters
- $image : TImage|null
Return values
$thissetInsertDatetime()
public
setInsertDatetime(DateTime|null $insertDatetime) : $this
Parameters
- $insertDatetime : DateTime|null
Return values
$thissetOfferSets()
public
setOfferSets(Collection<int, TOfferSet>|array<int, TOfferSet> $offerSets) : $this
Parameters
- $offerSets : Collection<int, TOfferSet>|array<int, TOfferSet>
Return values
$thissetPrices()
public
setPrices(Collection<int, TPrice>|array<int, TPrice> $prices) : $this
Parameters
- $prices : Collection<int, TPrice>|array<int, TPrice>
Return values
$thissetPriority()
public
setPriority(int $priority) : $this
Parameters
- $priority : int
Return values
$thissetProductSet()
public
setProductSet(TProductSet|null $productSet) : $this
Parameters
- $productSet : TProductSet|null
Return values
$thissetStartDatetime()
public
setStartDatetime(DateTime|null $startDatetime) : $this
Parameters
- $startDatetime : DateTime|null
Return values
$thissetTranslations()
public
setTranslations(Collection<int, TTranslation>|array<int, TTranslation> $translations) : $this
Parameters
- $translations : Collection<int, TTranslation>|array<int, TTranslation>
Return values
$thistranslationCollectionInit()
public
translationCollectionInit() : void
getTraitsRecursive()
Walks the trait list recursively and collects nested traits too.
private
static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
- $traits : array<string, string>