• PHP reference
  • Services
  • Billing

Plan

class Services\Billing\Plan extends Model

Class Plan

Properties

integer $id

ModelRelations $relations

string $name

string $price_user

string $price_gb

int $users_active_only

string $frequency

('monthly' or 'yearly')

Methods

array getUserTiers()

Get all user pricing tiers.

Returns an array that has as a key the amount of users from which the tier becomes active, and the price per user in that tier as the value.

Return Value

  • array

Exceptions

float getUserTiersPrice(integer $users_amount)

Get the price PER USER in a specific tier, which depends on the amount of users in $users_amount.

Parameters

  • integer $users_amount The amount of users to determine the correct tier

Return Value

  • float

Exceptions

integer getCountGbs(Community|integer $community)

Get the number of GBs in a certain community.

Parameters

Return Value

  • integer

integer getCountActiveUsers(integer|Community $community, integer $since_time)

Get the amount of active users since $since_time in a community.

Note that this only takes into account users created in that community, not users linked to the community that were created in another community.

Parameters

  • integer|Community $community
  • integer $since_time Since when to check for active users.

Return Value

  • integer

integer getCountUsers(Community|integer $community)

Get number of users to count for billing in a certain community, based on if the plan only counts active users and whether it is monthly/yearly.

Parameters

Return Value

  • integer

Inherited from Fillable

static boolean|Fillable create($fields)

Insert a new entry into the model's database table.

Parameters

  • $fields

Return Value

Inherited from Model

__construct(mixed $source = null, boolean $disable_global = false)

Model constructor. Pass in an ID (numeric) or object to start the model.

Parameters

  • mixed $source
  • boolean $disable_global

static Model[] getAll(integer $limit = null)

Get array of all table rows as model instances.

Parameters

  • integer $limit Maximum number of entries to retrieve

Return Value

static integer getCount(array|string $where = null)

Get the number of items in the model that match the query.

Parameters

  • array|string $where Array or SQL query component to build a WHERE ... query.

Return Value

  • integer

static Model|null find(integer $id)

Get the item of this model with the given ID if it exists. Returns null otherwise.

Note that any value passed to this function is converted into an integer!

Parameters

  • integer $id

Return Value

static Model|null findWith(string|array $field, mixed $value = null)

Check if an item with a given field value (exact match) exists.

Parameters

  • string|array $field
  • mixed $value

Return Value

static Model|null getBy(string|array $field, mixed $value = null)

Get item by a specific field (exact match). Returns null on failure.

Parameters

  • string|array $field
  • mixed $value

Return Value

static Model[] getManyBy(string|array $field, mixed $value = null)

Get array of items that have a specific field value (exact match).

Parameters

  • string|array $field
  • mixed $value

Return Value

static boolean exists(integer $id)

Check if an item with a given ID exists.

Parameters

  • integer $id

Return Value

  • boolean

static boolean existsWith(string $field, mixed $value = null)

Check if an item with a given field value (exact match) exists.

Parameters

  • string $field
  • mixed $value

Return Value

  • boolean

boolean update(string|array $field, mixed $value = null)

Update a field of this entry.

Parameters

  • string|array $field
  • mixed $value

Return Value

  • boolean

boolean del()

Delete the resource from the database.

Return Value

  • boolean

object barebones()

Get a bare bones version of the Model (without db, relations, etc.).

Return Value

  • object