update Device full CRUD

This commit is contained in:
2020-10-13 13:40:49 +07:00
parent 64e62ca3ce
commit 03e03c7e13
20 changed files with 1170 additions and 77 deletions

View File

@@ -10,24 +10,22 @@ use app\models\Device;
/**
* DeviceSearch represents the model behind the search form of `app\models\Device`.
*/
class DeviceSearch extends Device
{
class DeviceSearch extends Device {
/**
* {@inheritdoc}
*/
public function rules()
{
public function rules() {
return [
[['id', 'status', 'type', 'area_id', 'created_at', 'modified_at'], 'integer'],
[['name', 'serial', 'ip_address'], 'safe'],
[['id', 'status', 'type', 'area_id'], 'integer'],
[['name', 'serial', 'ip_address'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
public function scenarios() {
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
@@ -39,8 +37,7 @@ class DeviceSearch extends Device
*
* @return ActiveDataProvider
*/
public function search($params)
{
public function search($params) {
$query = Device::find();
// add conditions that should always apply here
@@ -68,9 +65,10 @@ class DeviceSearch extends Device
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'serial', $this->serial])
->andFilterWhere(['like', 'ip_address', $this->ip_address]);
->andFilterWhere(['like', 'serial', $this->serial])
->andFilterWhere(['like', 'ip_address', $this->ip_address]);
return $dataProvider;
}
}