Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace backendmodelssearch;
- use Yii;
- use yiibaseModel;
- use yiidataActiveDataProvider;
- use commonmodelsTruck;
- /**
- * ArticleSearch represents the model behind the search form about `commonmodelsArticle`.
- */
- class TruckSearch extends Truck
- {
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['id'], 'integer'],
- [['id', 'type_id', 'name', 'carrying'], 'safe'],
- ];
- }
- /**
- * @inheritdoc
- */
- public function scenarios()
- {
- // bypass scenarios() implementation in the parent class
- return Model::scenarios();
- }
- /**
- * Creates data provider instance with search query applied
- * @return ActiveDataProvider
- */
- public function search($params)
- {
- $query = Truck::find();
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- ]);
- if (!($this->load($params) && $this->validate())) {
- return $dataProvider;
- }
- $query->andFilterWhere([
- 'id' => $this->id,
- 'type_id' => $this->type_id,
- 'name' => $this->name,
- 'carrying' => $this->carrying,
- 'status' => $this->status,
- ]);
- /*$query->andFilterWhere(['like', 'slug', $this->slug])
- ->andFilterWhere(['like', 'title', $this->title])
- ->andFilterWhere(['like', 'body', $this->body]);*/
- return $dataProvider;
- }
- }
Add Comment
Please, Sign In to add comment