50], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'category_id' => 'Category ID', 'category_name' => 'Category Name', 'scenc_introduce' => 'Scenc Introduce', 'scenc_play' => 'Scenc Play', 'folk_customs' => 'Folk Customs', 'local_specialities' => 'Local Specialities', 'travel_tips' => 'Travel Tips', ]; } /** * Function Description:根据Category_id获取行程攻略 * Function Name: getItinerary * @param $categoryId * @return array|ActiveRecord[] * @author 田玲菲 */ public function getItinerary($categoryId){ $select = [ 'id', 'category_id', 'category_name', 'scenc_introduce'=>new Expression("IFNULL(scenc_introduce,'')"), 'scenc_play'=>new Expression("IFNULL(scenc_play,'')"), 'folk_customs'=>new Expression("IFNULL(folk_customs,'')"), 'local_specialities'=>new Expression("IFNULL(local_specialities,'')"), 'travel_tips'=>new Expression("IFNULL(travel_tips,'')") ]; $result = self::find()->select($select)->where('category_id = '.$categoryId)->asArray()->all(); return $result; } /** * Function Description:新增行程攻略 * Function Name: addItinerary * @param $param * @return bool * @author 田玲菲 */ public function addItinerary($param){ $this->category_id = $param['category_id']; $this->category_name = $param['category_name']; if($param['scenc_introduce'] != ''){ $this->scenc_introduce = $param['scenc_introduce']; } if($param['scenc_play'] != ''){ $this->scenc_play = $param['scenc_play']; } if($param['folk_customs'] != ''){ $this->folk_customs = $param['folk_customs']; } if($param['local_specialities'] != ''){ $this->local_specialities = $param['local_specialities']; } if($param['travel_tips'] != ''){ $this->travel_tips = $param['travel_tips']; } return $this->save(); } /** * Function Description:修改行程攻略 * Function Name: changeItinerary * @param $param * @return bool * @author 田玲菲 */ public function changeItinerary($param){ $row = self::find()->from(self::tableName())->where(['category_id'=>$param['category_id']])->one(); $row->category_name = $param['category_name']; $row->scenc_introduce = $param['scenc_introduce']; $row->scenc_play = $param['scenc_play']; $row->folk_customs = $param['folk_customs']; $row->local_specialities = $param['local_specialities']; $row->travel_tips = $param['travel_tips']; return $row->save(); } }