ulvis.paste.net

Paste Search Dynamic
Recent pastes
Model TarifSearch
  1. <?php
  2.  
  3. namespace frontend\models;
  4.  
  5. use Yii;
  6. use yii\base\Model;
  7. use yii\data\ActiveDataProvider;
  8. use frontend\models\TarifCargo;
  9.  
  10. /**
  11.  * TarifCargoSearch represents the model behind the search form of `frontend\models\TarifCargo`.
  12.  */
  13. class TarifCargoSearch extends TarifCargo
  14. {
  15.     /**
  16.      * {@inheritdoc}
  17.      */
  18.     public function rules()
  19.     {
  20.         return [
  21.             [['tcargo_id', 'lead_time'], 'integer'],
  22.             [['service_id', 'origin', 'origin_name', 'destination', 'destination_name'], 'safe'],
  23.             [['rate', 'admin_fee'], 'number'],
  24.         ];
  25.     }
  26.  
  27.     /**
  28.      * {@inheritdoc}
  29.      */
  30.     public function scenarios()
  31.     {
  32.         // bypass scenarios() implementation in the parent class
  33.         return Model::scenarios();
  34.     }
  35.  
  36.     /**
  37.      * Creates data provider instance with search query applied
  38.      *
  39.      * @param array $params
  40.      *
  41.      * @return ActiveDataProvider
  42.      */
  43.     public function search($params)
  44.     {
  45.         $query = TarifCargo::find();
  46.  
  47.         // add conditions that should always apply here
  48.  
  49.         $dataProvider = new ActiveDataProvider([
  50.             'query' => $query,
  51.         ]);
  52.  
  53.         $this->load($params);
  54.  
  55.         if (!$this->validate()) {
  56.             // uncomment the following line if you do not want to return any records when validation fails
  57.             // $query->where('0=1');
  58.             return $dataProvider;
  59.         }
  60.  
  61.         // grid filtering conditions
  62.         $query->andFilterWhere([
  63.             'tcargo_id' => $this->tcargo_id,
  64.             'rate' => $this->rate,
  65.             'admin_fee' => $this->admin_fee,
  66.             'lead_time' => $this->lead_time,
  67.              'massa' => $this->massa,
  68.  
  69.         ]);
  70.  
  71.         $query->andFilterWhere(['like', 'service_id', $this->service_id])
  72.             ->andFilterWhere(['like', 'origin', $this->origin])
  73.             ->andFilterWhere(['like', 'origin_name', $this->origin_name])
  74.             ->andFilterWhere(['like', 'destination', $this->destination])
  75.             ->andFilterWhere(['like', 'destination_name', $this->destination_name]);
  76.  
  77.         return $dataProvider;
  78.     }
  79. }
Parsed in 0.037 seconds