class Product extends BaseModel implements HasMedia (View source)

Traits

Properties

protected array $additionalSearchFields

Define the additional fields we want to index.

from  Searchable
protected array $additionalFilterableFields

Define the additional filterable fields.

from  Searchable
protected array $additionalSortableFields

Define the additional sortable fields.

from  Searchable
protected array $filterable

Define our base filterable attributes.

protected array $sortable

Define our base sortable attributes.

protected array $fillable

Define which attributes should be fillable during mass assignment.

protected array $casts

Define which attributes should be cast.

int $id
?int $brand_id
int $product_type_id
string $status
array $attribute_data
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.

MorphOne
thumbnail()

Relationship for thumbnail.

from  HasMedia
void
registerMediaCollections()

No description

from  HasMedia
void
registerMediaConversions(Media $media = null)

No description

from  HasMedia
LogOptions
getActivitylogOptions()

Get the log options for the activity log.

static 
bootHasChannels()

No description

Channel>
channels()

Get all of the models channels.

scheduleChannel($channel, DateTime $startsAt = null, DateTime $endsAt = null)

No description

MorphToMany
activeChannels()

Return the active channels relationship.

Builder
scopeChannel(Builder $query, Channel|iterable $channel = null, DateTime $startsAt = null, DateTime $endsAt = null)

Apply the channel scope to the query

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.

Tag>
tags()

Get the tags

from  HasTags
syncTags(Collection $tags)

No description

from  HasTags
void
validateScheduling(Collection $models)

Return whether or not the models provided are suitable for scheduling.

void
schedule(Relation $relation, mixed $models, DateTime $starts = null, DateTime $ends = null, array $pivotData = [])

Schedule models for a given relation.

void
unschedule(Relation $relation, mixed $models, array $pivotData = [])

Unschedule models for a relation.

BelongsToMany
customerGroups()

Return the customer groups relationship.

void
scheduleCustomerGroup(mixed $models, DateTime $starts = null, DateTime $ends = null, array $pivotData = [])

Schedule models against customer groups.

void
unscheduleCustomerGroup(mixed $models, array $pivotData = [])

Unschedule models against a customer group.

Builder
applyCustomerGroupScope(Builder $query, Collection $groupIds, DateTime $startsAt, DateTime $endsAt)

Apply customer group scope.

Builder
scopeCustomerGroup(Builder $query, CustomerGroup|iterable $customerGroup = null, DateTime $startsAt = null, DateTime $endsAt = null)

Apply the customer group scope

static void
bootHasUrls()

Boot the trait.

from  HasUrls
urls()

Get all of the models urls.

from  HasUrls
defaultUrl()

No description

from  HasUrls
getSearchableAttributes()

{@inheritDoc}

array
getFilterableAttributes()

Return our base attributes we want filterable.

void
addFilterableAttributes(array $attributes)

Add additional fields to filter on.

void
addSortableAttributes(array $attributes)

Add additional sortable attributes.

array
getSortableAttributes()

Return our base attributes we want sortable.

getObservableEvents()

{@inheritDoc}

void
addSearchableAttribute(string $key, string|mixed $value)

Add an attribute into the additional searchable fields.

toSearchableArray()

{@inheritDoc}

searchableUsing()

{@inheritDoc}

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

Handle dynamic static method calls into the model.

string
searchableAs()

Get the name of the index associated with the model.

static ProductFactory
newFactory()

Return a new factory instance for the model.

array
mappedAttributes()

Returns the attributes to be stored against this model.

BelongsTo
productType()

Return the product type relation.

MorphMany
images()

Return the product images relation.

HasMany
variants()

Return the product variants relation.

BelongsToMany
collections()

Return the product collections relation.

HasMany
associations()

Return the associations relationship.

HasMany
inverseAssociations()

Return the associations relationship.

void
associate(mixed $product, string $type)

Associate a product to another with a type.

void
dissociate(mixed $product, string $type = null)

Dissociate a product to another with a type.

BelongsTo
brand()

Return the brand relationship.

Builder
scopeStatus(Builder $query, string $status)

Apply the status scope.

HasManyThrough
prices()

Return the prices relationship.

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

MorphOne thumbnail()

Relationship for thumbnail.

Return Value

MorphOne

void registerMediaCollections()

No description

Return Value

void

void registerMediaConversions(Media $media = null)

No description

Parameters

Media $media

Return Value

void

LogOptions getActivitylogOptions()

Get the log options for the activity log.

Return Value

LogOptions

static bootHasChannels()

No description

Channel> channels()

Get all of the models channels.

Return Value

Channel>

scheduleChannel($channel, DateTime $startsAt = null, DateTime $endsAt = null)

No description

Parameters

$channel
DateTime $startsAt
DateTime $endsAt

MorphToMany activeChannels()

Return the active channels relationship.

Return Value

MorphToMany

Builder scopeChannel(Builder $query, Channel|iterable $channel = null, DateTime $startsAt = null, DateTime $endsAt = null)

Apply the channel scope to the query

Parameters

Builder $query
Channel|iterable $channel
DateTime $startsAt
DateTime $endsAt

Return Value

Builder

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

Tag> tags()

Get the tags

Return Value

Tag>

syncTags(Collection $tags)

No description

Parameters

Collection $tags

abstract protected void validateScheduling(Collection $models)

Return whether or not the models provided are suitable for scheduling.

Parameters

Collection $models

Return Value

void

protected void schedule(Relation $relation, mixed $models, DateTime $starts = null, DateTime $ends = null, array $pivotData = [])

Schedule models for a given relation.

Parameters

Relation $relation
mixed $models
DateTime $starts
DateTime $ends
array $pivotData

Return Value

void

protected void unschedule(Relation $relation, mixed $models, array $pivotData = [])

Unschedule models for a relation.

Parameters

Relation $relation
mixed $models
array $pivotData

Return Value

void

BelongsToMany customerGroups()

Return the customer groups relationship.

Return Value

BelongsToMany

void scheduleCustomerGroup(mixed $models, DateTime $starts = null, DateTime $ends = null, array $pivotData = [])

Schedule models against customer groups.

Parameters

mixed $models
DateTime $starts
DateTime $ends
array $pivotData

Return Value

void

void unscheduleCustomerGroup(mixed $models, array $pivotData = [])

Unschedule models against a customer group.

Parameters

mixed $models
array $pivotData

Return Value

void

Builder applyCustomerGroupScope(Builder $query, Collection $groupIds, DateTime $startsAt, DateTime $endsAt)

Apply customer group scope.

Parameters

Builder $query
Collection $groupIds
DateTime $startsAt
DateTime $endsAt

Return Value

Builder

Builder scopeCustomerGroup(Builder $query, CustomerGroup|iterable $customerGroup = null, DateTime $startsAt = null, DateTime $endsAt = null)

Apply the customer group scope

Parameters

Builder $query
CustomerGroup|iterable $customerGroup
DateTime $startsAt
DateTime $endsAt

Return Value

Builder

static void bootHasUrls()

Boot the trait.

Return Value

void

urls()

Get all of the models urls.

defaultUrl()

No description

getSearchableAttributes()

{@inheritDoc}

array getFilterableAttributes()

Return our base attributes we want filterable.

Return Value

array

void addFilterableAttributes(array $attributes)

Add additional fields to filter on.

Parameters

array $attributes

Return Value

void

void addSortableAttributes(array $attributes)

Add additional sortable attributes.

Parameters

array $attributes

Return Value

void

array getSortableAttributes()

Return our base attributes we want sortable.

Return Value

array

getObservableEvents()

{@inheritDoc}

void addSearchableAttribute(string $key, string|mixed $value)

Add an attribute into the additional searchable fields.

Parameters

string $key
string|mixed $value

Return Value

void

toSearchableArray()

{@inheritDoc}

searchableUsing()

{@inheritDoc}

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

Handle dynamic static method calls into the model.

Parameters

string $method
array $parameters

Return Value

mixed

string searchableAs()

Get the name of the index associated with the model.

Return Value

string

static protected ProductFactory newFactory()

Return a new factory instance for the model.

Return Value

ProductFactory

array mappedAttributes()

Returns the attributes to be stored against this model.

Return Value

array

BelongsTo productType()

Return the product type relation.

Return Value

BelongsTo

MorphMany images()

Return the product images relation.

Return Value

MorphMany

HasMany variants()

Return the product variants relation.

Return Value

HasMany

BelongsToMany collections()

Return the product collections relation.

Return Value

BelongsToMany

HasMany associations()

Return the associations relationship.

Return Value

HasMany

HasMany inverseAssociations()

Return the associations relationship.

Return Value

HasMany

void associate(mixed $product, string $type)

Associate a product to another with a type.

Parameters

mixed $product
string $type

Return Value

void

void dissociate(mixed $product, string $type = null)

Dissociate a product to another with a type.

Parameters

mixed $product
string $type

Return Value

void

BelongsTo brand()

Return the brand relationship.

Return Value

BelongsTo

Builder scopeStatus(Builder $query, string $status)

Apply the status scope.

Parameters

Builder $query
string $status

Return Value

Builder

HasManyThrough prices()

Return the prices relationship.

Return Value

HasManyThrough