public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'cliente' => array(self::BELONGS_TO, 'User', 'customer'),
'encomendaLinhas' => array(self::HAS_MANY, 'EncomendaLinha', 'encomenda'),
);
}
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
Yii::import('application.modules.admin.models.User');
$criteria=new CDbCriteria;
$criteria->compare('idencomenda',$this->idencomenda);
$criteria->compare('createDate',$this->createDate,true);
$criteria->compare('totalValue',$this->totalValue,true);
$criteria->compare('quantity',$this->quantity,true);
$criteria->compare('confirmed',$this->confirmed);
$criteria->compare('paid',$this->confirmed);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
public $client_nome;
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
Yii::import('application.modules.admin.models.User');
$criteria=new CDbCriteria;
$criteria->with = array('cliente');// I have added this line
$criteria->compare('idencomenda',$this->idencomenda);
$criteria->compare('createDate',$this->createDate,true);
$criteria->compare('totalValue',$this->totalValue,true);
$criteria->compare('quantity',$this->quantity,true);
$criteria->compare('confirmed',$this->confirmed);
$criteria->compare('paid',$this->confirmed);
$criteria->compare('cliente.nome',$this->client_nome, true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'sort'=>array(
'attributes'=>array(
'client_nome'=>array(
'asc'=>'cliente.nome',
'desc'=>'cliente.nome DESC',
),
'*',
),
),
));
}
Add client_nome to safe on search if you want to include in filter search. Hope it works