• PHP reference
  • Models

Group

class Group extends Model

Represents a group of people within a community.

Properties

integer $id

ModelRelations $relations

int $community

int $parent

string $title

int $admin_only

int $level

Methods

static boolean exists(integer $id, integer|Community $community = null)

Check if a group with a given ID exists.

Parameters

Return Value

  • boolean

User[] getMembers()

Get User objects for all of the group's members.

Return Value

Group|null getParent()

Get parent group object, or null.

Return Value

Community getCommunity()

Returns Community object for group.

Return Value

boolean isAdminOnly()

Whether group is admin-only.

Return Value

  • boolean

boolean addUser(integer|User $user, integer $weight = 200)

Add a user to the group.

Parameters

  • integer|User $user
  • integer $weight

Return Value

  • boolean

boolean removeUser(integer|User $user)

Remove a user from the group.

Parameters

  • integer|User $user

Return Value

  • boolean

boolean remove(boolean $cleanRelations = true)

Remove the whole group.

Parameters

  • boolean $cleanRelations

Return Value

  • boolean

boolean setPermission(string $key, integer $value)

Set a permission for the users of the group.

Parameters

  • string $key Permission key
  • integer $value Permission value (-1 for inherit, 0 for deny, 1 for allow)

Return Value

  • boolean

static boolean updatePermission(string $key, integer $value, integer $group, string $type = 'group')

Set permission for a certain group or community.

Parameters

  • string $key Permission key
  • integer $value Permission value (-1 for inherit, 0 for deny, 1 for allow)
  • integer $group ID of group or community
  • string $type Set to 'group' (default) or 'community'

Return Value

  • boolean

static Group|false createWithTitle(string $title, integer|Community $community, integer $parent, boolean $admin = false)

Create a new group. Returns group object after successful creation, or false otherwise.

Parameters

  • string $title
  • integer|Community $community
  • integer $parent
  • boolean $admin

Return Value

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.

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