<?php

/**
 * This is the model base class for the table "brindes".
 * DO NOT MODIFY THIS FILE! It is automatically generated by giix.
 * If any changes are necessary, you must set or override the required
 * property or method in class "Brindes".
 *
 * Columns in table "brindes" available as properties of the model,
 * followed by relations of table "brindes" available as properties of the model.
 *
 * @property integer $BRI_ID
 * @property string $BRI_DESC
 * @property string $BRI_STATUS
 *
 * @property BrindesAtendimentos[] $BrindesAtendimentos
 */
class Brindes extends GxActiveRecord {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function tableName() {
        return 'brindes';
    }

    public static function label($n = 1) {
        return Yii::t('app', 'Brinde|Brindes', $n);
    }

    public static function representingColumn() {
        return 'BRI_DESC';
    }

    public function rules() {
        return array(
            array('BRI_DESC, BRI_STATUS', 'required'),
            array('BRI_DESC', 'length', 'max' => 255),
            array('BRI_STATUS', 'length', 'max' => 1),
            array('BRI_ID, BRI_DESC, BRI_STATUS', 'safe', 'on' => 'search'),
            );
    }

    public function relations() {
        return array(
            'BrindesAtendimentos' => array(self::HAS_MANY, 'BrindesAtendimentos', 'BRICOD'),
            );
    }

    public function pivotModels() {
        return array(
            );
    }

    public function attributeLabels() {
        return array(
            'BRI_ID'              => 'Código',
            'BRI_DESC'            => 'Nome',
            'BRI_STATUS'          => 'Status',
            'BrindesAtendimentos' => 'Brindes atendimentos',
            );
    }

    public function search() {
        $criteria = new CDbCriteria;

        $criteria->compare('BRI_ID', $this->BRI_ID);
        $criteria->compare('BRI_DESC', $this->BRI_DESC, true);
        $criteria->compare('BRI_STATUS', $this->BRI_STATUS, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
            'pagination' => array(
                'pageSize' => 20,
                )
            )
        );
    }

}
