implement mobile devices in reception
This commit is contained in:
89
frontend/models/MobileDeviceSearch.php
Normal file
89
frontend/models/MobileDeviceSearch.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use common\components\Helper;
|
||||
use common\models\MobileDevice;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\db\Query;
|
||||
|
||||
/**
|
||||
* EventSearch represents the model behind the search form about `common\models\Event`.
|
||||
*/
|
||||
class MobileDeviceSearch extends MobileDevice
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = new Query();
|
||||
|
||||
$query->select([
|
||||
'card.id_card as card_id',
|
||||
'card.number as card_number',
|
||||
'mobile_device.id as device_id',
|
||||
'mobile_device.device_name as device_name',
|
||||
'mobile_device.status as device_status',
|
||||
'mobile_device.created_at as device_created_at',
|
||||
]);
|
||||
|
||||
$query->from("mobile_device");
|
||||
$query->innerJoin('customer', 'customer.id_customer_card = mobile_device.id_card');
|
||||
$query->innerJoin('card', 'card.id_card = mobile_device.id_card');
|
||||
$query->andWhere(['card.id_card' => $this->id_card]);
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' => [
|
||||
'defaultOrder' => [
|
||||
'device_created_at' => SORT_DESC
|
||||
],
|
||||
'attributes' => Helper::mkYiiSortItems([
|
||||
['device_created_at'],
|
||||
['device_status'],
|
||||
]),
|
||||
]
|
||||
]);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
// $query->andFilterWhere([
|
||||
// 'event.id' => $this->id,
|
||||
// ]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user