• PHP reference
  • Models

Reseller

class Reseller extends AttributedModel

Reseller model.

Properties

integer $id

ModelRelations $relations

static array $features

An array of all community features that can be turned on and off.

string $application_domain

string $application_name

string $application_color

string $application_favicon

string $application_touchicon

string $application_description

string $application_keywords

string $application_ga_code

string $application_homepage

string $billing_plan

string $xero_id

string $api_endpoint

(magic)

Methods

boolean get_from_domain(string $source)

Get a reseller based on the domain name used.

Parameters

  • string $source Domain name (optionally including subdomain)

Return Value

  • boolean True if successful match, false if no match found

Application patch_application(Application $application)

Update an Application instance based on the data of this reseller, like logo, favicon and Google Analytics tracking code.

Parameters

Return Value

string get_api_endpoint()

Get the preferred API base URL for Communities in this Reseller account.

Return Value

  • string

Community[] communities(boolean $include_suspended = false)

Returns an array of Community instances that are part of this Reseller account.

Parameters

  • boolean $include_suspended

Return Value

boolean owns_community(integer|Community $cid)

Check whether a community with this ID belongs to this Reseller account.

Parameters

  • integer|Community $cid The Community ID to check

Return Value

  • boolean

stdClass[] recipes()

Returns a list of saved community recipes for this Reseller account.

Return Value

boolean|mixed recipe_add(Community|integer $community, string $title, array $features = [])

Create a new recipe from a certain community to save as part of this Reseller account.

Parameters

  • Community|integer $community
  • string $title
  • array $features

Return Value

  • boolean|mixed

stdClass|null recipe_get(integer $id)

Get a recipe with a specific ID belonging to this Reseller account.

Parameters

  • integer $id

Return Value

boolean|mixed recipe_remove(integer $id)

Remove a recipe with a specific ID belonging ot this Reseller account.

Parameters

  • integer $id

Return Value

  • boolean|mixed

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

Inherited from AttributedModel

mixed attr(string $key, null $value = null)

Get or set a value on the model object.

Parameters

  • string $key
  • null $value

Return Value

  • mixed

mixed val(string $key, null $value = null)

Get or set a value on the model object. Alias for attr().

Parameters

  • string $key
  • null $value

Return Value

  • mixed

array attributes()

Get all metadata values for a model object.

Return Value

  • array

array vals()

Get all metadata values for a model object. Alias for attributes().

Return Value

  • array

static mixed|null getAttribute(string $type, integer $modelId, string $attributeKey, null $scope = null, boolean $cache = true)

Static function to get a parameter without having to retrieve the base model.

Parameters

  • string $type
  • integer $modelId
  • string $attributeKey
  • null $scope
  • boolean $cache

Return Value

  • mixed|null

boolean is(string $key)

Convenience method for testing if a model value is truthy (bool true, string 'true', int 1, string '1').

Parameters

  • string $key

Return Value

  • boolean

Inherited from HasPrivateDatabase

array getDatabaseCredentials()

Get an array containing keys database, hostname, username, password, which can be used to create a connection to the private database from a module.

Return Value

  • array

DB getDatabase()

Get a database instance that is connected to the model-specific private database.

Return Value

See also

  • https://docs.includable.com/components/community-databases/