예제 #1
0
파일: Hotsale.php 프로젝트: weiyiyi/base
 public function init()
 {
     parent::init();
     $this->on(self::EVENT_BEFORE_INSERT, function ($event) {
         $time = TIMESTAMP;
         $this->create_time = $time;
         $this->update_time = $time;
     });
     $this->on(self::EVENT_BEFORE_UPDATE, function ($event) {
         $this->update_time = TIMESTAMP;
     });
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Hotsale::find();
     $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;
     }
     $query->andFilterWhere(['id' => $this->id, 'price' => $this->price, 'status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'delect' => $this->delect]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'sexual_taste', $this->sexual_taste]);
     return $dataProvider;
 }
예제 #3
0
파일: Hotsale.php 프로젝트: weiyiyi/base
 public function rules()
 {
     return array_merge(parent::rules(), [[['name'], 'required', 'message' => '商品名不能为空']]);
 }
예제 #4
0
파일: Order.php 프로젝트: weiyiyi/base
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getHotsale()
 {
     return $this->hasOne(Hotsale::className(), ['id' => 'hotsale_id']);
 }