TravelLine.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\admin\model;
  3. use support\Db;
  4. use support\Model;
  5. /**
  6. * 路线模型
  7. * Class Users
  8. * @package app\api\model
  9. */
  10. class TravelLine extends Model
  11. {
  12. const ROLE_STATUS = 1;
  13. const IS_DEL_YES = 1;
  14. const IS_DEL_NO = 0;
  15. const GOODS_IS_SHOW = [
  16. self::IS_DEL_YES => '已删除',
  17. self::IS_DEL_NO => '未删除'
  18. ];
  19. /**
  20. * The table associated with the model.
  21. *
  22. * @var string
  23. */
  24. protected $table = 'travel_line';
  25. public $timestamps = false;
  26. /**
  27. * Notes:获取线路列表
  28. * @param string $keywords
  29. * @param int $page
  30. * @param int $limit
  31. * @return array
  32. * User: YCP
  33. * Date: 2023/05/16
  34. */
  35. public static function getLineList()
  36. {
  37. $list = static::select('*')
  38. ->where(['line_is_del'=>static::IS_DEL_NO])
  39. ->orderBy('line_create_time','DESC')
  40. ->get();
  41. foreach ($list as &$v) {
  42. $v['line_tags'] = explode(",",$v['line_tags']);
  43. }
  44. $count = static::where(['line_is_del'=>static::IS_DEL_NO])
  45. ->count();
  46. return [$list, $count];
  47. }
  48. //时间格式
  49. public function getLineCreateTimeAttribute($value)
  50. {
  51. return date('Y-m-d H:i:s', $value);
  52. }
  53. //关联套餐内项目
  54. public function LineDate(){
  55. return $this->hasMany(TravelDate::class,'line_id','line_id')->where(['date_is_del'=>0]);
  56. }
  57. //关联店铺
  58. public function Shop(){
  59. return $this->belongsTo(MerchantShop::class,'shop_id','shop_id');
  60. }
  61. }