ProductVariant
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
Get new instance of the registered model.
Handle dynamic and static method calls into the model.
Forward a method call to the model only when calling a method on the model.
Register a model event with the dispatcher.
Fire the given event for the model.
Remove all the event listeners for the model.
Translate a given attribute based on passed locale.
Translate a value from attribute data.
Handle dynamic static method calls into the model.
Return a new factory instance for the model.
The related product.
Return the tax class relationship.
Return the related product option values.
Get the purchasable prices.
Return the unit quantity for the variant.
Return the tax class.
Return the purchasable tax reference.
Return what type of purchasable this is, i.e. physical,digital,shipping.
Returns whether the purchasable item is shippable.
Return the description for the purchasable.
Return the option for this purchasable.
{@inheritDoc}
Return a unique string which identifies the purchasable item.
No description
Return the thumbnail for the purchasable item.
Details
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.
protected bool
forwardCallsWhen(string $method, Model $model)
Forward a method call to the model only when calling a method on the model.
static protected void
registerModelEvent(string $event, QueuedClosure|Closure|string $callback)
Register a model event with the dispatcher.
protected 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.
PricingManager
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 protected 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.
TaxClass
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.