12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace app\admin\model;
- use support\Db;
- use support\Model;
- /**
- * 路线模型
- * Class Users
- * @package app\api\model
- */
- class TravelLine extends Model
- {
- const ROLE_STATUS = 1;
- const IS_DEL_YES = 1;
- const IS_DEL_NO = 0;
- const GOODS_IS_SHOW = [
- self::IS_DEL_YES => '已删除',
- self::IS_DEL_NO => '未删除'
- ];
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'travel_line';
- public $timestamps = false;
- /**
- * Notes:获取线路列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: YCP
- * Date: 2023/05/16
- */
- public static function getLineList()
- {
- $list = static::select('*')
- ->where(['line_is_del'=>static::IS_DEL_NO])
- ->orderBy('line_create_time','DESC')
- ->get();
- foreach ($list as &$v) {
- $v['line_tags'] = explode(",",$v['line_tags']);
- }
-
- $count = static::where(['line_is_del'=>static::IS_DEL_NO])
- ->count();
- return [$list, $count];
- }
- //时间格式
- public function getLineCreateTimeAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- //关联套餐内项目
- public function LineDate(){
- return $this->hasMany(TravelDate::class,'line_id','line_id')->where(['date_is_del'=>0]);
- }
- //关联店铺
- public function Shop(){
- return $this->belongsTo(MerchantShop::class,'shop_id','shop_id');
- }
- }
|