Documentation

CustomerProduct extends IsBillableAbstractClass
in package
Uses HasFactory, LogsActivityAllDirty, Notifiable, PowerJoins, SoftDeletes, WithoutJobs

Table of Contents

table  = "crm__customer_products"
Table name, as constant, used to avoid table name duplication across the source code base.
$activityLogName  : string
$billable_directly  : bool
$billable_hourly  : bool
$billable_hourly_cost  : float
$billable_monthly  : bool
$billable_monthly_cost  : float
$billable_multiplier  : float
$billable_one_time  : bool
$billable_one_time_cost  : float
$billable_per_usage  : bool
$billable_per_usage_cost  : float
$billable_upon_relation  : bool
$billable_upon_relation_class  : string
$billable_upon_relation_fk  : string
$deleted_at  : Carbon
$is_billable  : bool
$price_list_expires_at  : int
$attributes  : array<string|int, mixed>
Default attributes for the billable models.
$casts  : mixed
$fillable  : array<int, string>
The attributes that are mass assignable.
$jobsEnabled  : bool
This parameter specify if jobs should be launched or not
$table  : string
Table name
_isBillable()  : bool
This function is used to determinate if a model is ready to be billed.
_isBillableDirectly()  : bool
This function is used to determinate if a model is ready to be billed.
billingEntries()  : MorphMany
customer()  : BelongsTo
getActivitylogOptions()  : LogOptions
Specifies which model properties should be logged in the activy log
getBillableOwnerModel()  : $this
getCustomerProduct()  : $this
getInvoiceItemDescription()  : string
impl()  : MorphTo
priceList()  : BelongsTo
priceListEntity()  : MorphOne
product()  : BelongsTo
promotionsCustomers()  : MorphMany
related()  : MorphTo
saveWithoutJobs()  : mixed
whereAuthUser()  : array<string|int, mixed>|Collection
withoutJobs()  : mixed
Executes the callback disabling the jobs launching
_getUsage()  : float
Called by the custom attribute `usage`. This function must be overwritten by the class that should implement how usage is calculated
billableHourly()  : Attribute
billableHourlyCost()  : Attribute
billableMonthly()  : Attribute
billableMonthlyCost()  : Attribute
billableMultiplier()  : Attribute
billableOneTime()  : Attribute
billableOneTimeCost()  : Attribute
billablePerUsage()  : Attribute
billablePerUsageCost()  : Attribute
billableUponRelation()  : Attribute
billableUponRelationClass()  : Attribute
billableUponRelationFk()  : Attribute
boot()  : void
Boot the model and register the events
bootIsBillable()  : void
newFactory()  : CustomerProductFactory
Get the Factory Class
usage()  : Attribute
`usage` custom attribute (only getter).

Constants

table

Table name, as constant, used to avoid table name duplication across the source code base.

public mixed table = "crm__customer_products"
Tags
const

string

Properties

$attributes

Default attributes for the billable models.

protected array<string|int, mixed> $attributes = ['is_billable' => false, 'billable_directly' => false]

IMPORTANT! This should be redeclared if the chid class has its own default attributes.

$casts

protected mixed $casts = ['status' => \Athomos\Bennu\Modules\Crm\Enums\CustomerProductStatus::class, 'is_billable' => 'boolean', 'billable_directly' => 'boolean']

$fillable

The attributes that are mass assignable.

protected array<int, string> $fillable = ['customer_id', 'product_id', 'external_id', 'external_source']

$jobsEnabled

This parameter specify if jobs should be launched or not

protected bool $jobsEnabled = true

Methods

_isBillable()

This function is used to determinate if a model is ready to be billed.

public _isBillable([bool|null $originIsBillable = null ]) : bool

Should be overwritten by models that needs a custom logic. If a model do not specialize this function the provided parameter will be returned, otherwise the attribute of the model. IMPORTANT!!! In the specialized version of this function always check the provided parameter, as in some cases a model may have been set on is_billable = false

Parameters
$originIsBillable : bool|null = null
Return values
bool

_isBillableDirectly()

This function is used to determinate if a model is ready to be billed.

public _isBillableDirectly([bool $originIsBillableDirectly = null ]) : bool

Should be overwritten by models that needs a custom logic. If a model do not specialize this function the provided parameter will be returned, otherwise the attribute of the model. IMPORTANT!!! In the specialized version of this function always check the provided parameter, as in some cases a model may have been set on is_billable = false

Parameters
$originIsBillableDirectly : bool = null
Return values
bool

billingEntries()

public billingEntries() : MorphMany
Return values
MorphMany

customer()

public customer() : BelongsTo
Return values
BelongsTo

getActivitylogOptions()

Specifies which model properties should be logged in the activy log

public getActivitylogOptions() : LogOptions
Return values
LogOptions

getBillableOwnerModel()

public getBillableOwnerModel() : $this
Return values
$this

getCustomerProduct()

public getCustomerProduct() : $this
Return values
$this

getInvoiceItemDescription()

public getInvoiceItemDescription([array<string|int, mixed> $changes = [] ]) : string
Parameters
$changes : array<string|int, mixed> = []
Return values
string

priceList()

public priceList() : BelongsTo
Return values
BelongsTo

priceListEntity()

public priceListEntity() : MorphOne
Return values
MorphOne

promotionsCustomers()

public promotionsCustomers() : MorphMany
Return values
MorphMany

saveWithoutJobs()

public saveWithoutJobs() : mixed
Return values
mixed

whereAuthUser()

public whereAuthUser(AuthUser $authUser) : array<string|int, mixed>|Collection
Parameters
$authUser : AuthUser
Return values
array<string|int, mixed>|Collection

withoutJobs()

Executes the callback disabling the jobs launching

public withoutJobs(callable $callback) : mixed
Parameters
$callback : callable
Return values
mixed

_getUsage()

Called by the custom attribute `usage`. This function must be overwritten by the class that should implement how usage is calculated

protected _getUsage() : float
Return values
float

billableHourly()

protected billableHourly() : Attribute
Return values
Attribute

billableHourlyCost()

protected billableHourlyCost() : Attribute
Return values
Attribute

billableMonthly()

protected billableMonthly() : Attribute
Return values
Attribute

billableMonthlyCost()

protected billableMonthlyCost() : Attribute
Return values
Attribute

billableMultiplier()

protected billableMultiplier() : Attribute
Return values
Attribute

billableOneTime()

protected billableOneTime() : Attribute
Return values
Attribute

billableOneTimeCost()

protected billableOneTimeCost() : Attribute
Return values
Attribute

billablePerUsage()

protected billablePerUsage() : Attribute
Return values
Attribute

billablePerUsageCost()

protected billablePerUsageCost() : Attribute
Return values
Attribute

billableUponRelation()

protected billableUponRelation() : Attribute
Return values
Attribute

billableUponRelationClass()

protected billableUponRelationClass() : Attribute
Return values
Attribute

billableUponRelationFk()

protected billableUponRelationFk() : Attribute
Return values
Attribute

boot()

Boot the model and register the events

protected static boot() : void
Return values
void

usage()

`usage` custom attribute (only getter).

protected usage() : Attribute

It returns the current usage of the entity for billable purpose.

Return values
Attribute

float Usage

Search results