# 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

| Name | Description |
|  --- | --- |
| `STATUS_PENDING` |  |
| `STATUS_ACTIVE` |  |
| `STATUS_SUSPENDED` |  |
| `STATUS_CANCELLED` |  |


## Methods

### boot

```php
public static function boot()
```

### getServiceActual

```php
public function getServiceActual(): self
```

### getServiceSurrogate

```php
public function getServiceSurrogate(): self
```

### hasServiceSurrogate

```php
public function hasServiceSurrogate(): bool
```

### getServiceClient

```php
public function getServiceClient(): Client
```

### getServiceProperties

```php
public function getServiceProperties(): Properties
```

### scopeUserId

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |
| `int` | `$userId` |  |


**Returns** `Builder`

### scopeDomain

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |
| `string` | `$domain` |  |


**Returns** `Builder`

### scopeActive

```php
public function scopeActive(Builder $query): Builder
```

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### scopeMarketConnect

```php
public function scopeMarketConnect(Builder $query): Builder
```

Filter for only MarketConnect services.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### scopeIsConsideredActive

```php
public function scopeIsConsideredActive(Builder $query): Builder
```

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### scopeIsNotRecurring

```php
public function scopeIsNotRecurring(Builder $query): Builder
```

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### isRecurring

```php
public function isRecurring(): bool
```

**Returns** `bool`

### client

```php
public function client()
```

Each service belongs to one client.

**Returns** `\Illuminate\Database\Eloquent\Relations\BelongsTo`

### product

```php
public function product()
```

Each service is an instance of a product.

**Returns** `\Illuminate\Database\Eloquent\Relations\BelongsTo`

### paymentGateway

```php
public function paymentGateway()
```

Each service has many payment gateway records.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### addons

```php
public function addons()
```

Each service can have many addons

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### order

```php
public function order()
```

A domain belongs to a single order.

**Returns** `BelongsTo`

### promotion

```php
public function promotion()
```

Each service can have one promotion.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasOne`

### cancellationRequests

```php
public function cancellationRequests()
```

Each service can have many cancellation requests

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### ssl

```php
public function ssl()
```

Each service could have many ssl records.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### invoices

```php
public function invoices(): BelongsToMany
```

### hasAvailableUpgrades

```php
public function hasAvailableUpgrades()
```

Determine if a service has available upgrades.

**Returns** `bool`

### failedActions

```php
public function failedActions()
```

**Returns** `HasMany`

### customFieldValues

```php
public function customFieldValues()
```

**Returns** `HasMany\|CustomFieldValue`

### configOptions

```php
public function configOptions(): HasMany
```

### getServicePropertiesAttribute

```php
public function getServicePropertiesAttribute()
```

**Returns** `Properties`

### getNonTerminalStatuses

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

```php
public function canBeUpgraded()
```

Determine if service can be upgraded.

**Returns** `bool`

### shouldShowUpgradeLink

```php
public function shouldShowUpgradeLink(): bool
```

### hasOutstandingInvoices

```php
public function hasOutstandingInvoices(): bool
```

### isService

```php
public function isService()
```

Is this entity a service?

**Returns** `bool`

### isAddon

```php
public function isAddon()
```

Is this entity an addon?

**Returns** `bool`

### serverModel

```php
public function serverModel()
```

Each service may belong to a server.

**Returns** `\Illuminate\Database\Eloquent\Relations\belongsTo`

### legacyProvision

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

```php
public function getMetricProvider()
```

**Returns** `ProviderInterface\|null`

### metrics

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

**Returns** `ServiceMetric[]`

### getLink

```php
public function getLink()
```

### getUniqueIdentifierValue

```php
public function getUniqueIdentifierValue($uniqueIdField)
```

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$uniqueIdField` |  |


**Returns** `mixed\|string\|null`

### getHexColorFromStatus

```php
public function getHexColorFromStatus(): string
```

### getParentalSiblingAttribute

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

```php
public function getProvisioningModuleName(): string
```

### getCustomActionData

```php
public function getCustomActionData(): array
```

**Returns** `array`

### getFirstPaymentAmount

```php
public function getFirstPaymentAmount(): Price
```

### getRecurringAmount

```php
public function getRecurringAmount(): Price
```

### getBillingCycle

```php
public function getBillingCycle(): string
```

### getPaymentGateway

```php
public function getPaymentGateway(): Gateway
```

### getNextDueDate

```php
public function getNextDueDate(): ?Carbon
```

### getPromotions

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

```php
public function getServiceProduct(): ?Product
```

### getInvoicingServiceItemType

```php
public function getInvoicingServiceItemType(): string
```

### getInvoicingServiceFirstPaymentAmount

```php
public function getInvoicingServiceFirstPaymentAmount(): Price
```

### getInvoicingServiceRecurringAmount

```php
public function getInvoicingServiceRecurringAmount(): Price
```

### isServiceMetricUsage

```php
public function isServiceMetricUsage(): bool
```

### data

```php
public function data()
```