Alias.php 1.04 KB
<?php 
/**
 * Alias model
 *
 */

class Alias extends ActiveRecord
{
    /**
     * REST behavior
     */
    public function behaviors()
    {
        return array(
            'RestModelBehavior' => array(
                'class' => 'WRestModelBehavior',
            )
        );
    }
    
    
    /**
     * Returns current model
     */
    public static function model( $className = __CLASS__ )
    {
        return parent::model($className);
    }
    
    
    /**
     * Return table name to which this model is related
     */
    public function tableName()
    {
        return 'aliases';
    }
    

    /**
     * Return table primary key name
     */
    public function primaryKey()
    {
        return 'id';
    }
    
    /**
     * Model rules
     */
    public function rules(){
        return array(
            array('alias, recipient, comment', 'default', 'on' => 'insert'),
            array('alias, recipient', 'required', 'on' => 'insert'),
            array('id, alias, recipient, comment', 'default', 'on' => 'update')
        );
    }
}