|
- <?php
- /**
- * 数据库表类 sys_itinerary
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm LoginController.php
- * Create By 2017/10/18 11:06 $
- */
-
- namespace common\models;
-
- use yii\db\ActiveRecord;
- use yii\db\Expression;
-
- /**
- * 数据库表类 sys_itinerary.
- * @property integer $id
- * @property integer $category_id
- * @property string $category_name
- * @property string $scenc_introduce
- * @property string $scenc_play
- * @property string $folk_customs
- * @property string $local_specialities
- * @property string $travel_tips
- */
- class SysItinerary extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'sys_itinerary';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['category_id'], 'integer'],
- [['scenc_introduce', 'scenc_play', 'folk_customs', 'local_specialities', 'travel_tips'], 'string'],
- [['category_name'], 'string', 'max' => 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();
- }
- }
|