class OrderSearch extends Order
{
public $mobile;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['mobile'], 'safe'],
];
}
} public function search($params)
{
$query = Order::find();
// add conditions that should always apply here
$query->joinWith('customer');
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
]);
$query->andFilterWhere(['like', 'customer.mobile', $this->mobile]);
return $dataProvider;
} [
'attribute' => 'mobile',
'label' => 'Customer Mobile',
'format' => 'raw',
'value' => function ($dataProvider) {
return (isset($dataProvider->customer->mobile) ? $dataProvider->customer->mobile : '');
},
],
برچسب:
نویسنده: خنجی