Class mdm\admin\models\Menu
Inheritance | mdm\admin\models\Menu » yii\db\ActiveRecord » yii\db\BaseActiveRecord » yii\base\Model » yii\base\Component » yii\base\Object |
---|---|
Implements | ArrayAccess, IteratorAggregate, yii\base\Arrayable, yii\db\ActiveRecordInterface |
Uses Traits | yii\base\ArrayableTrait |
Subclasses | mdm\admin\models\searchs\Menu |
Available since version | 1.0 |
This is the model class for table "menu".
Public Properties
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Component |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\Object |
__get() | PHP getter magic method. | yii\db\BaseActiveRecord |
__isset() | Checks if a property value is null. | yii\db\BaseActiveRecord |
__set() | PHP setter magic method. | yii\db\BaseActiveRecord |
__unset() | Sets a component property to be null. | yii\db\BaseActiveRecord |
activeAttributes() | Returns the attribute names that are subject to validation in the current scenario. | yii\base\Model |
addError() | Adds a new error to the specified attribute. | yii\base\Model |
afterDelete() | This method is invoked after deleting a record. | yii\db\BaseActiveRecord |
afterFind() | This method is called when the AR object is created and populated with the query result. | yii\db\BaseActiveRecord |
afterSave() | This method is called at the end of inserting or updating a record. | yii\db\BaseActiveRecord |
afterValidate() | This method is invoked after validation ends. | yii\base\Model |
attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
attributeLabels() | Returns the attribute labels. | mdm\admin\models\Menu |
attributes() | Returns the list of all attribute names of the record. | yii\db\ActiveRecordInterface |
beforeDelete() | This method is invoked before deleting a record. | yii\db\BaseActiveRecord |
beforeSave() | This method is called at the beginning of inserting or updating a record. | yii\db\BaseActiveRecord |
beforeValidate() | This method is invoked before validation starts. | yii\base\Model |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component |
className() | Returns the fully qualified name of this class. | yii\base\Object |
clearErrors() | Removes errors for all attributes or a single attribute. | yii\base\Model |
createValidators() | Creates validator objects based on the validation rules specified in rules(). | yii\base\Model |
delete() | Deletes the table row corresponding to this active record. | yii\db\BaseActiveRecord |
deleteAll() | Deletes rows in the table using the provided conditions. | yii\db\BaseActiveRecord |
detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
equals() | Returns a value indicating whether the given active record is the same as the current one. | yii\db\BaseActiveRecord |
extraFields() | Returns the list of fields that can be expanded further and returned by toArray(). | yii\base\ArrayableTrait |
fields() | Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. | yii\base\ArrayableTrait |
filterParent() | Use to loop detected. | mdm\admin\models\Menu |
find() | Creates an ActiveQuery instance for query purpose. | yii\db\ActiveRecordInterface |
findAll() | Returns a list of active record models that match the specified primary key value(s) or a set of column values. | yii\db\BaseActiveRecord |
findBySql() | Creates an yii\db\ActiveQuery instance with a given SQL statement. | yii\db\ActiveRecord |
findOne() | Returns a single active record model instance by a primary key or an array of column values. | yii\db\BaseActiveRecord |
formName() | Returns the form name that this model class should use. | yii\base\Model |
generateAttributeLabel() | Generates a user friendly attribute label based on the give attribute name. | yii\base\Model |
getActiveValidators() | Returns the validators applicable to the current $scenario. | yii\base\Model |
getAttribute() | Returns the named attribute value. | yii\db\BaseActiveRecord |
getAttributeLabel() | Returns the text label for the specified attribute. | yii\db\BaseActiveRecord |
getAttributes() | Returns attribute values. | yii\base\Model |
getBehavior() | Returns the named behavior object. | yii\base\Component |
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
getDb() | Returns the database connection used by this AR class. | mdm\admin\models\Menu |
getDirtyAttributes() | Returns the attribute values that have been modified since they are loaded or saved most recently. | yii\db\BaseActiveRecord |
getErrors() | Returns the errors for all attribute or a single attribute. | yii\base\Model |
getFirstError() | Returns the first error of the specified attribute. | yii\base\Model |
getFirstErrors() | Returns the first error of every attribute in the model. | yii\base\Model |
getIsNewRecord() | Returns a value indicating whether the current record is new. | yii\db\BaseActiveRecord |
getIterator() | Returns an iterator for traversing the attributes in the model. | yii\base\Model |
getMenuParent() | Get menu parent | mdm\admin\models\Menu |
getMenus() | Get menu children | mdm\admin\models\Menu |
getOldAttribute() | Returns the old value of the named attribute. | yii\db\BaseActiveRecord |
getOldAttributes() | Returns the old attribute values. | yii\db\BaseActiveRecord |
getOldPrimaryKey() | Returns the old primary key value(s). | yii\db\BaseActiveRecord |
getPrimaryKey() | Returns the primary key value(s). | yii\db\BaseActiveRecord |
getRelatedRecords() | Returns all populated related records. | yii\db\BaseActiveRecord |
getRelation() | Returns the relation object with the specified name. | yii\db\BaseActiveRecord |
getSavedRoutes() | Get saved routes. | mdm\admin\models\Menu |
getScenario() | Returns the scenario that this model is used in. | yii\base\Model |
getTableSchema() | Returns the schema information of the DB table associated with this AR class. | yii\db\ActiveRecord |
getValidators() | Returns all the validators declared in rules(). | yii\base\Model |
hasAttribute() | Returns a value indicating whether the model has an attribute with the specified name. | yii\db\BaseActiveRecord |
hasErrors() | Returns a value indicating whether there is any validation error. | yii\base\Model |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMany() | Declares a has-many relation. |
yii\db\BaseActiveRecord |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component |
hasOne() | Declares a has-one relation. |
yii\db\BaseActiveRecord |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component |
init() | Initializes the object. | yii\db\BaseActiveRecord |
insert() | Inserts the record into the database using the attribute values of this record. | yii\db\ActiveRecordInterface |
instantiate() | Creates an active record instance. | yii\db\BaseActiveRecord |
isAttributeActive() | Returns a value indicating whether the attribute is active in the current scenario. | yii\base\Model |
isAttributeChanged() | Returns a value indicating whether the named attribute has been changed. | yii\db\BaseActiveRecord |
isAttributeRequired() | Returns a value indicating whether the attribute is required. | yii\base\Model |
isAttributeSafe() | Returns a value indicating whether the attribute is safe for massive assignments. | yii\base\Model |
isPrimaryKey() | Returns a value indicating whether the given set of attributes represents the primary key for this model | yii\db\BaseActiveRecord |
isRelationPopulated() | Check whether the named relation has been populated with records. | yii\db\BaseActiveRecord |
isTransactional() | Returns a value indicating whether the specified operation is transactional in the current $scenario. | yii\db\ActiveRecord |
link() | Establishes the relationship between two models. | yii\db\BaseActiveRecord |
load() | Populates the model with the data from end user. | yii\base\Model |
loadDefaultValues() | Loads default values from database table schema | yii\db\ActiveRecord |
loadMultiple() | Populates a set of models with the data from end user. | yii\base\Model |
markAttributeDirty() | Marks an attribute dirty. | yii\db\BaseActiveRecord |
off() | Detaches an existing event handler from this component. | yii\base\Component |
offsetExists() | Returns whether there is an element at the specified offset. | yii\db\BaseActiveRecord |
offsetGet() | Returns the element at the specified offset. | yii\base\Model |
offsetSet() | Sets the element at the specified offset. | yii\base\Model |
offsetUnset() | Sets the element value at the specified offset to null. | yii\db\BaseActiveRecord |
on() | Attaches an event handler to an event. | yii\base\Component |
onUnsafeAttribute() | This method is invoked when an unsafe attribute is being massively assigned. | yii\base\Model |
optimisticLock() | Returns the name of the column that stores the lock version for implementing optimistic locking. | yii\db\BaseActiveRecord |
populateRecord() | Populates an active record object using a row of data from the database/storage. | yii\db\BaseActiveRecord |
populateRelation() | Populates the named relation with the related records. | yii\db\BaseActiveRecord |
primaryKey() | Returns the primary key name(s) for this AR class. | yii\db\ActiveRecordInterface |
refresh() | Repopulates this active record with the latest data. | yii\db\BaseActiveRecord |
rules() | Returns the validation rules for attributes. | mdm\admin\models\Menu |
safeAttributes() | Returns the attribute names that are safe to be massively assigned in the current scenario. | yii\base\Model |
save() | Saves the current record. | yii\db\BaseActiveRecord |
scenarios() | Returns a list of scenarios and the corresponding active attributes. | yii\base\Model |
setAttribute() | Sets the named attribute value. | yii\db\BaseActiveRecord |
setAttributes() | Sets the attribute values in a massive way. | yii\base\Model |
setIsNewRecord() | Sets the value indicating whether the record is new. | yii\db\BaseActiveRecord |
setOldAttribute() | Sets the old value of the named attribute. | yii\db\BaseActiveRecord |
setOldAttributes() | Sets the old attribute values. | yii\db\BaseActiveRecord |
setScenario() | Sets the scenario for the model. | yii\base\Model |
tableName() | Declares the name of the database table associated with this AR class. | mdm\admin\models\Menu |
toArray() | Converts the model into an array. | yii\base\ArrayableTrait |
transactions() | Declares which DB operations should be performed within a transaction in different scenarios. | yii\db\ActiveRecord |
trigger() | Triggers an event. | yii\base\Component |
unlink() | Destroys the relationship between two models. | yii\db\BaseActiveRecord |
unlinkAll() | Destroys the relationship in current model. | yii\db\BaseActiveRecord |
update() | Saves the changes to this active record into the associated database table. | yii\db\BaseActiveRecord |
updateAll() | Updates the whole table using the provided attribute values and conditions. | yii\db\BaseActiveRecord |
updateAllCounters() | Updates the whole table using the provided counter changes and conditions. | yii\db\BaseActiveRecord |
updateAttributes() | Updates the specified attributes. | yii\db\BaseActiveRecord |
updateCounters() | Updates one or several counter columns for the current AR object. | yii\db\BaseActiveRecord |
validate() | Performs the data validation. | yii\base\Model |
validateMultiple() | Validates multiple models. | yii\base\Model |
Protected Methods
Method | Description | Defined By |
---|---|---|
deleteInternal() | Deletes an ActiveRecord without considering transaction. | yii\db\ActiveRecord |
findByCondition() | Finds ActiveRecord instance(s) by the given condition. | yii\db\BaseActiveRecord |
insertInternal() | Inserts an ActiveRecord into DB without considering transaction. | yii\db\ActiveRecord |
resolveFields() | Determines which fields can be returned by toArray(). | yii\base\ArrayableTrait |
updateInternal() | yii\db\BaseActiveRecord |
Events
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_DELETE | \yii\db\Event | An event that is triggered after a record is deleted. | yii\db\BaseActiveRecord |
EVENT_AFTER_FIND | \yii\db\Event | An event that is triggered after the record is created and populated with query result. | yii\db\BaseActiveRecord |
EVENT_AFTER_INSERT | \yii\db\Event | An event that is triggered after a record is inserted. | yii\db\BaseActiveRecord |
EVENT_AFTER_UPDATE | \yii\db\Event | An event that is triggered after a record is updated. | yii\db\BaseActiveRecord |
EVENT_AFTER_VALIDATE | yii\base\Event | An event raised at the end of validate() | yii\base\Model |
EVENT_BEFORE_DELETE | yii\base\ModelEvent | An event that is triggered before deleting a record. | yii\db\BaseActiveRecord |
EVENT_BEFORE_INSERT | yii\base\ModelEvent | An event that is triggered before inserting a record. | yii\db\BaseActiveRecord |
EVENT_BEFORE_UPDATE | yii\base\ModelEvent | An event that is triggered before updating a record. | yii\db\BaseActiveRecord |
EVENT_BEFORE_VALIDATE | yii\base\ModelEvent | An event raised at the beginning of validate(). | yii\base\Model |
EVENT_INIT | \yii\db\Event | An event that is triggered when the record is initialized via init(). | yii\db\BaseActiveRecord |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
OP_ALL | 7 | All three operations: insert, update, delete. This is a shortcut of the expression: OP_INSERT | OP_UPDATE | OP_DELETE. | yii\db\ActiveRecord |
OP_DELETE | 4 | The delete operation. This is mainly used when overriding transactions() to specify which operations are transactional. | yii\db\ActiveRecord |
OP_INSERT | 1 | The insert operation. This is mainly used when overriding transactions() to specify which operations are transactional. | yii\db\ActiveRecord |
OP_UPDATE | 2 | The update operation. This is mainly used when overriding transactions() to specify which operations are transactional. | yii\db\ActiveRecord |
SCENARIO_DEFAULT | 'default' | The name of the default scenario. | yii\base\Model |
Property Details
The validators applicable to the current $scenario.
Attribute values (name => value).
List of behaviors attached to this component
The changed attribute values (name-value pairs)
Errors for all attributes or the specified attribute. Empty array is returned if no error. Note that when returning errors for all attributes, the result is a two-dimensional array, like the following:
[
'username' => [
'Username is required.',
'Username must contain only word characters.',
],
'email' => [
'Email address is invalid.',
]
]
The first errors. The array keys are the attribute names, and the array values are the corresponding error messages. An empty array will be returned if there is no error.
Whether the record is new and should be inserted when calling save().
An iterator for traversing the items in the list.
The old attribute values (name-value pairs)
The old primary key value. An array (column name => column value) is returned if the primary key
is composite or $asArray
is true. A string is returned otherwise (null will be returned if
the key value is null).
The primary key value. An array (column name => column value) is returned if the primary key
is composite or $asArray
is true. A string is returned otherwise (null will be returned if
the key value is null).
An array of related records indexed by relation names.
The scenario that this model is in. Defaults to SCENARIO_DEFAULT.
All the validators declared in the model.
Method Details
Returns the attribute labels.
Attribute labels are mainly used for display purpose. For example, given an attribute
firstName
, we can declare a label First Name
which is more user-friendly and can
be displayed to end users.
By default an attribute label is generated using generateAttributeLabel(). This method allows you to explicitly specify attribute labels.
Note, in order to inherit labels defined in the parent class, a child class needs to
merge the parent labels with child labels using functions such as array_merge()
.
array attributeLabels( ) | ||
return | array | Attribute labels (name => label) |
---|
Use to loop detected.
void filterParent( ) |
Returns the database connection used by this AR class.
By default, the "db" application component is used as the database connection. You may override this method if you want to use a different database connection.
yii\db\Connection getDb( ) | ||
return | yii\db\Connection | The database connection used by this AR class. |
---|
Get menu parent
yii\db\ActiveQuery getMenuParent( ) |
Get menu children
yii\db\ActiveQuery getMenus( ) |
Get saved routes.
array getSavedRoutes( ) |
Returns the validation rules for attributes.
Validation rules are used by validate() to check if attribute values are valid. Child classes may override this method to declare different validation rules.
Each rule is an array with the following structure:
[
['attribute1', 'attribute2'],
'validator type',
'on' => ['scenario1', 'scenario2'],
...other parameters...
]
where
- attribute list: required, specifies the attributes array to be validated, for single attribute you can pass string;
- validator type: required, specifies the validator to be used. It can be a built-in validator name, a method name of the model class, an anonymous function, or a validator class name.
- on: optional, specifies the scenarios array when the validation rule can be applied. If this option is not set, the rule will apply to all scenarios.
- additional name-value pairs can be specified to initialize the corresponding validator properties. Please refer to individual validator class API for possible properties.
A validator can be either an object of a class extending \mdm\admin\models\Validator, or a model class method (called inline validator) that has the following signature:
// $params refers to validation parameters given in the rule
function validatorName($attribute, $params)
In the above $attribute
refers to currently validated attribute name while $params
contains an array of
validator configuration options such as max
in case of string
validator. Currently validate attribute value
can be accessed as $this->[$attribute]
.
Yii also provides a set of \mdm\admin\models\Validator::builtInValidators. They each has an alias name which can be used when specifying a validation rule.
Below are some examples:
[
// built-in "required" validator
[['username', 'password'], 'required'],
// built-in "string" validator customized with "min" and "max" properties
['username', 'string', 'min' => 3, 'max' => 12],
// built-in "compare" validator that is used in "register" scenario only
['password', 'compare', 'compareAttribute' => 'password2', 'on' => 'register'],
// an inline validator defined via the "authenticate()" method in the model class
['password', 'authenticate', 'on' => 'login'],
// a validator of class "DateRangeValidator"
['dateRange', 'DateRangeValidator'],
];
Note, in order to inherit rules defined in the parent class, a child class needs to
merge the parent rules with child rules using functions such as array_merge()
.
array rules( ) | ||
return | array | Validation rules |
---|
Declares the name of the database table associated with this AR class.
By default this method returns the class name as the table name by calling \mdm\admin\models\Inflector::camel2id() with prefix \mdm\admin\models\Connection::tablePrefix. For example if \mdm\admin\models\Connection::tablePrefix is 'tbl_', 'Customer' becomes 'tbl_customer', and 'OrderItem' becomes 'tbl_order_item'. You may override this method if the table is not named after this convention.
string tableName( ) | ||
return | string | The table name |
---|