* @since 1.0.0 */ protected static array $columns = [ 'group_id' => ['name' => 'group_id', 'type' => 'int', 'internal' => 'id'], 'group_name' => ['name' => 'group_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], 'group_status' => ['name' => 'group_status', 'type' => 'int', 'internal' => 'status'], 'group_desc' => ['name' => 'group_desc', 'type' => 'string', 'internal' => 'description'], 'group_desc_raw' => ['name' => 'group_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'], 'group_created' => ['name' => 'group_created', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], ]; /** * Primary table. * * @var string * @since 1.0.0 */ protected static string $table = 'group'; /** * Primary field name. * * @var string * @since 1.0.0 */ protected static string $primaryField = 'group_id'; /** * Created at column * * @var string * @since 1.0.0 */ protected static string $createdAt = 'group_created'; /** * Has many relation. * * @var array * @since 1.0.0 */ protected static array $hasMany = [ 'accounts' => [ 'mapper' => AccountMapper::class, 'table' => 'account_group', 'external' => 'account_group_group', 'self' => 'account_group_account', ], ]; /** * Get groups which reference a certain module * * @param string $module Module * * @return array * * @since 1.0.0 */ public static function getPermissionForModule(string $module) : array { $query = self::getQuery(); $query->innerJoin(GroupPermissionMapper::getTable()) ->on(self::$table . '.group_id', '=', GroupPermissionMapper::getTable() . '.group_permission_group') ->where(GroupPermissionMapper::getTable() . '.group_permission_module', '=', $module); return self::getAllByQuery($query); } }