class Discount extends BaseModel (View source)

Traits

Properties

protected $guarded
protected array $casts

Define which attributes should be cast.

int $id
string $name
string $handle
?string $coupon
string $type
Carbon $starts_at
Carbon $ends_at
int $uses
?int $max_uses
int $priority
bool $stop
Carbon $created_at
Carbon $updated_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.

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 
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

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 DiscountFactory
newFactory()

Return a new factory instance for the model.

users()

No description

HasMany
purchasables()

Return the purchasables relationship.

purchasableConditions()

No description

purchasableLimitations()

No description

purchasableRewards()

No description

getType()

No description

HasMany
collections()

Return the collections relationship.

brands()

No description

Builder
scopeActive(Builder $query)

Return the active scope.

Builder
scopeProducts(Builder $query, iterable $productIds = [], string $type = null)

Return the products scope.

scopeUsable(Builder $query)

No description

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

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 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

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 protected DiscountFactory newFactory()

Return a new factory instance for the model.

Return Value

DiscountFactory

users()

No description

HasMany purchasables()

Return the purchasables relationship.

Return Value

HasMany

purchasableConditions()

No description

purchasableLimitations()

No description

purchasableRewards()

No description

getType()

No description

HasMany collections()

Return the collections relationship.

Return Value

HasMany

brands()

No description

Builder scopeActive(Builder $query)

Return the active scope.

Parameters

Builder $query

Return Value

Builder

Builder scopeProducts(Builder $query, iterable $productIds = [], string $type = null)

Return the products scope.

Parameters

Builder $query
iterable $productIds
string $type

Return Value

Builder

scopeUsable(Builder $query)

No description

Parameters

Builder $query