class ProductVariant extends BaseModel implements Purchasable (View source)

Traits

Properties

protected array $guarded

Define the guarded attributes.

protected $casts {@inheritDoc}
int $id
int $product_id
int $tax_class_id
array $attribute_data
?string $tax_ref
int $unit_quantity
?string $sku
?string $gtin
?string $mpn
?string $ean
?float $length_value
?string $length_unit
?float $width_value
?string $width_unit
?float $height_value
?string $height_unit
?float $weight_value
?string $weight_unit
?float $volume_value
?string $volume_unit
bool $shippable
int $stock
int $backorder
string $purchasable
Carbon $created_at
Carbon $updated_at
Carbon $deleted_at

Methods

Model
newInstance(array $attributes = [], bool $exists = false)

Get new instance of the registered model.

mixed
__call(string $method, array $parameters)

Handle dynamic and static method calls into the model.

Model
swap(string $newModelClass)

Swap the model implementation.

string
getMorphClass()

Get the class name of the base model.

bool
forwardCallsWhen(string $method, Model $model)

Forward a method call to the model only when calling a method on the model.

static void
registerModelEvent(string $event, QueuedClosure|Closure|string $callback)

Register a model event with the dispatcher.

mixed
fireModelEvent(string $event, bool $halt = true)

Fire the given event for the model.

static void
flushEventListeners()

Remove all the event listeners for the model.

__construct(array $attributes = [])

Create a new instance of the Model.

prices()

Get all of the models prices.

MorphMany
basePrices()

Return base prices query.

pricing()

Return a PricingManager for this model.

LogOptions
getActivitylogOptions()

Get the log options for the activity log.

static void
bootHasDimensions()

Method when trait is booted.

Converter
getLengthAttribute()

Getter for the length attribute.

Converter
getWidthAttribute()

Getter for the width attribute.

Converter
getHeightAttribute()

Getter for height attribute.

Converter
getWeightAttribute()

Getter for weight attribute.

Converter
getVolumeAttribute()

Getter for the volume attribute.

string
translate(string $attribute, string $locale = null)

Translate a given attribute based on passed locale.

string
translateAttribute(string $attribute, string $locale = null)

Translate a value from attribute data.

void
attr(...$params)

Shorthand to translate an attribute.

static mixed
__callStatic(string $method, array $parameters)

Handle dynamic static method calls into the model.

static ProductVariantFactory
newFactory()

Return a new factory instance for the model.

BelongsTo
product()

The related product.

BelongsTo
taxClass()

Return the tax class relationship.

BelongsToMany
values()

Return the related product option values.

Collection
getPrices()

Get the purchasable prices.

int
getUnitQuantity()

Return the unit quantity for the variant.

getTaxClass()

Return the tax class.

string|null
getTaxReference()

Return the purchasable tax reference.

string
getType()

Return what type of purchasable this is, i.e. physical,digital,shipping.

bool
isShippable()

Returns whether the purchasable item is shippable.

string
getDescription()

Return the description for the purchasable.

string|null
getOption()

Return the option for this purchasable.

getOptions()

{@inheritDoc}

string
getIdentifier()

Return a unique string which identifies the purchasable item.

images()

No description

string
getThumbnail()

Return the thumbnail for the purchasable item.

Details

Model newInstance(array $attributes = [], bool $exists = false)

Get new instance of the registered model.

Parameters

array $attributes
bool $exists

Return Value

Model

mixed __call(string $method, array $parameters)

Handle dynamic and static method calls into the model.

Parameters

string $method
array $parameters

Return Value

mixed

Model swap(string $newModelClass)

Swap the model implementation.

Parameters

string $newModelClass

Return Value

Model

string getMorphClass()

Get the class name of the base model.

Return Value

string

protected bool forwardCallsWhen(string $method, Model $model)

Forward a method call to the model only when calling a method on the model.

Parameters

string $method
Model $model

Return Value

bool

static protected void registerModelEvent(string $event, QueuedClosure|Closure|string $callback)

Register a model event with the dispatcher.

Parameters

string $event
QueuedClosure|Closure|string $callback

Return Value

void

protected mixed fireModelEvent(string $event, bool $halt = true)

Fire the given event for the model.

Parameters

string $event
bool $halt

Return Value

mixed

static void flushEventListeners()

Remove all the event listeners for the model.

Return Value

void

__construct(array $attributes = [])

Create a new instance of the Model.

Parameters

array $attributes

prices()

Get all of the models prices.

MorphMany basePrices()

Return base prices query.

Return Value

MorphMany

PricingManager pricing()

Return a PricingManager for this model.

Return Value

PricingManager

LogOptions getActivitylogOptions()

Get the log options for the activity log.

Return Value

LogOptions

static void bootHasDimensions()

Method when trait is booted.

Return Value

void

Converter getLengthAttribute()

Getter for the length attribute.

Return Value

Converter

Converter getWidthAttribute()

Getter for the width attribute.

Return Value

Converter

Converter getHeightAttribute()

Getter for height attribute.

Return Value

Converter

Converter getWeightAttribute()

Getter for weight attribute.

Return Value

Converter

Converter getVolumeAttribute()

Getter for the volume attribute.

Return Value

Converter

string translate(string $attribute, string $locale = null)

Translate a given attribute based on passed locale.

Parameters

string $attribute
string $locale

Return Value

string

string translateAttribute(string $attribute, string $locale = null)

Translate a value from attribute data.

Parameters

string $attribute
string $locale

Return Value

string

void attr(...$params)

Shorthand to translate an attribute.

Parameters

...$params

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Handle dynamic static method calls into the model.

Parameters

string $method
array $parameters

Return Value

mixed

static protected ProductVariantFactory newFactory()

Return a new factory instance for the model.

Return Value

ProductVariantFactory

BelongsTo product()

The related product.

Return Value

BelongsTo

BelongsTo taxClass()

Return the tax class relationship.

Return Value

BelongsTo

BelongsToMany values()

Return the related product option values.

Return Value

BelongsToMany

Collection getPrices()

Get the purchasable prices.

Return Value

Collection

int getUnitQuantity()

Return the unit quantity for the variant.

Return Value

int

TaxClass getTaxClass()

Return the tax class.

Return Value

TaxClass

string|null getTaxReference()

Return the purchasable tax reference.

Return Value

string|null

string getType()

Return what type of purchasable this is, i.e. physical,digital,shipping.

Return Value

string

bool isShippable()

Returns whether the purchasable item is shippable.

Return Value

bool

string getDescription()

Return the description for the purchasable.

Return Value

string

string|null getOption()

Return the option for this purchasable.

Return Value

string|null

getOptions()

{@inheritDoc}

string getIdentifier()

Return a unique string which identifies the purchasable item.

Return Value

string

images()

No description

string getThumbnail()

Return the thumbnail for the purchasable item.

Return Value

string