Blesta Source Documentation

States extends AppModel

States adhere to ISO 3166-2, and contain the native state/province/territory name. The format of ISO 3166-2 is [ISO 3166-1 alpha2 country code]-[subdivision code].

This model requires that the ISO 3166-2 code be split on the hyphen into its two parts.

Table of Contents

Methods

__construct() Initialize States
add() Add a state
delete() Delete a state by the ISO 3166-1 alpha2 country code and 3166-2 subdivision code
edit() Edit a state by the ISO 3166-1 alpha2 country code and 3166-2 subdivision code
get() Get a specific state/province/territory based ISO 3166-1 alpha2 country code and ISO 3166-2 subdivision code
getList() List all states for a given country (ISO 3166-1 alpha2)
getRules() Returns the rule set for adding/editing states
Methods

__construct()

Initialize States

public __construct() : mixed

add()

Add a state

public add(array<string|int, mixed> $vars) : mixed
Parameters
$vars : array<string|int, mixed>

An array of variable info including:

  • code The ISO 3166-2 alpha-numeric subdivision code
  • country_alpha2 The ISO 3166-1 alpha2 country code
  • name The native language subdivision name

delete()

Delete a state by the ISO 3166-1 alpha2 country code and 3166-2 subdivision code

public delete(string $country, string $code) : mixed
Parameters
$country : string

The ISO 3166-1 alpha2 country code

$code : string

The ISO 3166-2 subdivision code

edit()

Edit a state by the ISO 3166-1 alpha2 country code and 3166-2 subdivision code

public edit(string $country, string $code, array<string|int, mixed> $vars) : mixed
Parameters
$country : string

The ISO 3166-1 alpha2 country code

$code : string

The ISO 3166-2 subdivision code

$vars : array<string|int, mixed>

An array of variable info including:

  • name The native language subdivision name

get()

Get a specific state/province/territory based ISO 3166-1 alpha2 country code and ISO 3166-2 subdivision code

public get(string $country, string $code) : mixed
Parameters
$country : string

The ISO 3166-1 alpha2 country code to fetch on

$code : string

The ISO 3166-2 alpha-numeric subdivision code

Return values
mixed

An stdClass object representing the state, or false if none exist

getList()

List all states for a given country (ISO 3166-1 alpha2)

public getList([string $country = null ][, array<string|int, mixed> $order_by = ['name' => 'asc'] ]) : array<string|int, mixed>
Parameters
$country : string = null

The ISO 3166-1 alpha2 country code to fetch on

$order_by : array<string|int, mixed> = ['name' => 'asc']

A set of key/value fields to order by where each key is the field and each value is the direction (optional, default name ascending)

Return values
array<string|int, mixed>

An array of stdClass state objects

getRules()

Returns the rule set for adding/editing states

private getRules(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

An array of state info including:

  • code The state code
  • country_alpha2 The 2-character country code ISO 3166-2
  • name The name of the state in its native language
Return values
array<string|int, mixed>

State rules

Tags
subpackage

app.models

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results