public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     }
     $this->createTable(Timezone\Translation::tableName(), ['timezone_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'language' => $this->string(16)->notNull(), 'title' => $this->string(255)->notNull(), 'CONSTRAINT fk_timezones_timezone_translations_timezone_id FOREIGN KEY (timezone_id) REFERENCES ' . Timezone::tableName() . ' (id) ON DELETE CASCADE ON UPDATE CASCADE', 'PRIMARY KEY(timezone_id, language)'], $tableOptions);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Timezone::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'offset_gmt' => $this->offset_gmt, 'offset_dst' => $this->offset_dst, 'offset_raw' => $this->offset_raw, 'order_popular' => $this->order_popular, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'timezone', $this->timezone]);
     return $dataProvider;
 }
 public function down()
 {
     $this->dropTable(Timezone::tableName());
 }