Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

142 řádky
4.3 KiB

  1. <?php
  2. /**
  3. * 数据库表类 sys_itinerary
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm LoginController.php
  13. * Create By 2017/10/18 11:06 $
  14. */
  15. namespace common\models;
  16. use yii\db\ActiveRecord;
  17. use yii\db\Expression;
  18. /**
  19. * 数据库表类 sys_itinerary.
  20. * @property integer $id
  21. * @property integer $category_id
  22. * @property string $category_name
  23. * @property string $scenc_introduce
  24. * @property string $scenc_play
  25. * @property string $folk_customs
  26. * @property string $local_specialities
  27. * @property string $travel_tips
  28. */
  29. class SysItinerary extends ActiveRecord
  30. {
  31. /**
  32. * @inheritdoc
  33. */
  34. public static function tableName()
  35. {
  36. return 'sys_itinerary';
  37. }
  38. /**
  39. * @inheritdoc
  40. */
  41. public function rules()
  42. {
  43. return [
  44. [['category_id'], 'integer'],
  45. [['scenc_introduce', 'scenc_play', 'folk_customs', 'local_specialities', 'travel_tips'], 'string'],
  46. [['category_name'], 'string', 'max' => 50],
  47. ];
  48. }
  49. /**
  50. * @inheritdoc
  51. */
  52. public function attributeLabels()
  53. {
  54. return [
  55. 'id' => 'ID',
  56. 'category_id' => 'Category ID',
  57. 'category_name' => 'Category Name',
  58. 'scenc_introduce' => 'Scenc Introduce',
  59. 'scenc_play' => 'Scenc Play',
  60. 'folk_customs' => 'Folk Customs',
  61. 'local_specialities' => 'Local Specialities',
  62. 'travel_tips' => 'Travel Tips',
  63. ];
  64. }
  65. /**
  66. * Function Description:根据Category_id获取行程攻略
  67. * Function Name: getItinerary
  68. * @param $categoryId
  69. * @return array|ActiveRecord[]
  70. * @author 田玲菲
  71. */
  72. public function getItinerary($categoryId){
  73. $select = [
  74. 'id',
  75. 'category_id',
  76. 'category_name',
  77. 'scenc_introduce'=>new Expression("IFNULL(scenc_introduce,'')"),
  78. 'scenc_play'=>new Expression("IFNULL(scenc_play,'')"),
  79. 'folk_customs'=>new Expression("IFNULL(folk_customs,'')"),
  80. 'local_specialities'=>new Expression("IFNULL(local_specialities,'')"),
  81. 'travel_tips'=>new Expression("IFNULL(travel_tips,'')")
  82. ];
  83. $result = self::find()->select($select)->where('category_id = '.$categoryId)->asArray()->all();
  84. return $result;
  85. }
  86. /**
  87. * Function Description:新增行程攻略
  88. * Function Name: addItinerary
  89. * @param $param
  90. * @return bool
  91. * @author 田玲菲
  92. */
  93. public function addItinerary($param){
  94. $this->category_id = $param['category_id'];
  95. $this->category_name = $param['category_name'];
  96. if($param['scenc_introduce'] != ''){
  97. $this->scenc_introduce = $param['scenc_introduce'];
  98. }
  99. if($param['scenc_play'] != ''){
  100. $this->scenc_play = $param['scenc_play'];
  101. }
  102. if($param['folk_customs'] != ''){
  103. $this->folk_customs = $param['folk_customs'];
  104. }
  105. if($param['local_specialities'] != ''){
  106. $this->local_specialities = $param['local_specialities'];
  107. }
  108. if($param['travel_tips'] != ''){
  109. $this->travel_tips = $param['travel_tips'];
  110. }
  111. return $this->save();
  112. }
  113. /**
  114. * Function Description:修改行程攻略
  115. * Function Name: changeItinerary
  116. * @param $param
  117. * @return bool
  118. * @author 田玲菲
  119. */
  120. public function changeItinerary($param){
  121. $row = self::find()->from(self::tableName())->where(['category_id'=>$param['category_id']])->one();
  122. $row->category_name = $param['category_name'];
  123. $row->scenc_introduce = $param['scenc_introduce'];
  124. $row->scenc_play = $param['scenc_play'];
  125. $row->folk_customs = $param['folk_customs'];
  126. $row->local_specialities = $param['local_specialities'];
  127. $row->travel_tips = $param['travel_tips'];
  128. return $row->save();
  129. }
  130. }