Skip to content
Last updated

WHMCS\Service\Service

Class · extends AbstractModel · implements ServiceInterface, InvoicingServiceInterface, SubscriptionAwareInterface, ServicePricingInterface

A client-owned service.

A Service is an instance of a Product purchased by a Client by way of an Order and, optionally, provisioned to a Server by a provisioning module.

Services are attached to a Domain name. The status of the attached domain name is tracked here.

The payment gateway used, the recurring amount and billing cycle, as well as the initial payment used to activate this product are recorded here.

If the provisioning module provides instrumentation for tracking bandwidth and disk space usage, it is tracked and stored in this object.

If the Service requires a username and password to utilize, those are tracked here.

If this Service is suspended, the reason for the suspension is stored here. Instanced Services can also be made immune to automatic suspension by WHMCS, for a specific time period or until suspensions are intentionally re-allowed. This can allow the operator to cause a Service to remain active despite WHMCS's billing rules. (For example, the operator may flag the operator's own websites as immune from suspension, while utilizing all the other management features of WHMCS).

Dedicated IP addresses and the nameservers for the Domain attached to this Service are stored in this object.

This Service can act as a parent to various Service\Addons, which provide additional features beyond the configuration of the Product this Service was instanced from.

Any CancellationRequests for this server can also be accessed via this object.

Traits

  • DomainTraits
  • ProvisioningTraits
  • SubscriptionAwareTrait

Constants

NameDescription
STATUS_PENDING
STATUS_ACTIVE
STATUS_SUSPENDED
STATUS_CANCELLED

Methods

boot

public static function boot()

getServiceActual

public function getServiceActual(): self

getServiceSurrogate

public function getServiceSurrogate(): self

hasServiceSurrogate

public function hasServiceSurrogate(): bool

getServiceClient

public function getServiceClient(): Client

getServiceProperties

public function getServiceProperties(): Properties

scopeUserId

public function scopeUserId(Builder $query, int $userId): Builder

Parameters

TypeNameDescription
Builder$query
int$userId

Returns Builder

scopeDomain

public function scopeDomain(Builder $query, string $domain): Builder

Parameters

TypeNameDescription
Builder$query
string$domain

Returns Builder

scopeActive

public function scopeActive(Builder $query): Builder

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeMarketConnect

public function scopeMarketConnect(Builder $query): Builder

Filter for only MarketConnect services.

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeIsConsideredActive

public function scopeIsConsideredActive(Builder $query): Builder

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeIsNotRecurring

public function scopeIsNotRecurring(Builder $query): Builder

Parameters

TypeNameDescription
Builder$query

Returns Builder

isRecurring

public function isRecurring(): bool

Returns bool

client

public function client()

Each service belongs to one client.

Returns \Illuminate\Database\Eloquent\Relations\BelongsTo

product

public function product()

Each service is an instance of a product.

Returns \Illuminate\Database\Eloquent\Relations\BelongsTo

paymentGateway

public function paymentGateway()

Each service has many payment gateway records.

Returns \Illuminate\Database\Eloquent\Relations\HasMany

addons

public function addons()

Each service can have many addons

Returns \Illuminate\Database\Eloquent\Relations\HasMany

order

public function order()

A domain belongs to a single order.

Returns BelongsTo

promotion

public function promotion()

Each service can have one promotion.

Returns \Illuminate\Database\Eloquent\Relations\HasOne

cancellationRequests

public function cancellationRequests()

Each service can have many cancellation requests

Returns \Illuminate\Database\Eloquent\Relations\HasMany

ssl

public function ssl()

Each service could have many ssl records.

Returns \Illuminate\Database\Eloquent\Relations\HasMany

invoices

public function invoices(): BelongsToMany

hasAvailableUpgrades

public function hasAvailableUpgrades()

Determine if a service has available upgrades.

Returns bool

failedActions

public function failedActions()

Returns HasMany

customFieldValues

public function customFieldValues()

Returns HasMany\|CustomFieldValue

configOptions

public function configOptions(): HasMany

getServicePropertiesAttribute

public function getServicePropertiesAttribute()

Returns Properties

getNonTerminalStatuses

public static function getNonTerminalStatuses(): array

Status values representative of an entry that has further status values it could transition to.

Returns string[] — Array of Statuses as strings

canBeUpgraded

public function canBeUpgraded()

Determine if service can be upgraded.

Returns bool

public function shouldShowUpgradeLink(): bool

hasOutstandingInvoices

public function hasOutstandingInvoices(): bool

isService

public function isService()

Is this entity a service?

Returns bool

isAddon

public function isAddon()

Is this entity an addon?

Returns bool

serverModel

public function serverModel()

Each service may belong to a server.

Returns \Illuminate\Database\Eloquent\Relations\belongsTo

legacyProvision

public function legacyProvision()

Run provision action in legacy mode.

Legacy mode returns 'success' on success and an error message string on failure.

Returns string

getMetricProvider

public function getMetricProvider()

Returns ProviderInterface\|null

metrics

public function metrics($onlyBilledMetrics = false, $mode = null)

Returns ServiceMetric[]

public function getLink()

getUniqueIdentifierValue

public function getUniqueIdentifierValue($uniqueIdField)

Parameters

TypeNameDescription
string$uniqueIdField

Returns mixed\|string\|null

getHexColorFromStatus

public function getHexColorFromStatus(): string

getParentalSiblingAttribute

public function getParentalSiblingAttribute(): ?self

Locate another Service that appears to be related to this service in a parental relationship. This is despite $this Service not being an Addon to another Service. Thus a result from this method implies $this Service is a pseudo-addon. Eg. SSL service ordered independently, but with the same domain as a hosting Service; return the hosting Service as a "parent".

Returns self\|null

getProvisioningModuleName

public function getProvisioningModuleName(): string

getCustomActionData

public function getCustomActionData(): array

Returns array

getFirstPaymentAmount

public function getFirstPaymentAmount(): Price

getRecurringAmount

public function getRecurringAmount(): Price

getBillingCycle

public function getBillingCycle(): string

getPaymentGateway

public function getPaymentGateway(): Gateway

getNextDueDate

public function getNextDueDate(): ?Carbon

getPromotions

public function getPromotions(): SupportCollection

Currently we only have one promotion, but we are planning to have more than one in the future, so we should prepare for that.

Returns SupportCollection

getServiceProduct

public function getServiceProduct(): ?Product

getInvoicingServiceItemType

public function getInvoicingServiceItemType(): string

getInvoicingServiceFirstPaymentAmount

public function getInvoicingServiceFirstPaymentAmount(): Price

getInvoicingServiceRecurringAmount

public function getInvoicingServiceRecurringAmount(): Price

isServiceMetricUsage

public function isServiceMetricUsage(): bool

data

public function data()