CartVoucher
extends BaseEntity
in package
implements
IdentifiableInterface
uses
IdentifiableTrait
AbstractYes
Discount code applied in a persistent cart: only the code, no validation or value (price and validity are always verified by checkout, not by the cart).
Surrogate PK, same reason as CartItem. CartManager deduplicates the pair
(cart, code) case-insensitively in PHP (mb_strtolower) before building entities; the
unique index (case-insensitive collation) is only a fallback.
Tags
Attributes
- #[MappedSuperclass]
- #[TableAlias]
- $alias: 'cartVoucher'
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
Methods
- __construct() : mixed
- 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.
- getCart() : TCart|null
- getCode() : string
- getId() : int|null
- isPersisted() : bool
- setCart() : $this
- setCode() : $this
- setId() : $this
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$cart
protected
TCart|null
$cart
= null
$code
protected
string
$code
= ''
Attributes
- #[Column]
- $name: 'code'
- $type: 'string'
- $length: 64
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $name: 'cart_voucher_id'
- $type: 'integer'
- $options: ['unsigned' => true]
- #[GeneratedValue]
- #[Id]
Methods
__construct()
public
__construct([int|null $id = null ][, mixed $cart = null ][, string $code = '' ]) : mixed
Parameters
- $id : int|null = null
- $cart : mixed = null
- $code : string = ''
callInitMethods()
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>getCart()
public
getCart() : TCart|null
Return values
TCart|nullgetCode()
public
getCode() : string
Return values
stringgetId()
public
getId() : int|null
Return values
int|nullisPersisted()
public
isPersisted() : bool
Return values
boolsetCart()
public
setCart(TCart|null $cart) : $this
Parameters
- $cart : TCart|null
Return values
$thissetCode()
public
setCode(string $code) : $this
Parameters
- $code : string
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thisgetTraitsRecursive()
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>