erp/app/Models/Groups.php

69 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use App\Models\traits\Filter;
class Groups extends Model
{
use Filter;
//查询字段
public $fieldSearchable = [
'title',
'shop_id',
'status',
];
public function setStartTimeAttribute($value)
{
$time = strtotime($value);
$this->attributes['start_time'] = $time * 1000;
}
public function getStartTimeAttribute($value)
{
return date('Y-m-d H:i:s', $value / 1000);
}
public function setEndTimeAttribute($value)
{
$time = strtotime($value);
$this->attributes['end_time'] = $time * 1000;
}
public function getEndTimeAttribute($value)
{
return date('Y-m-d H:i:s', $value / 1000);
}
public function getStatusAttribute($value)
{
$map = [
-10 => '待发布/预览中',
-5 => '未开始',
1 => '跟团中',
20 => '已结束',
30 => '已删除',
];
return $map[$value];
}
public function getCreateStatusAttribute($value)
{
$map = [
1 => '创建成功',
2 => '创建失败',
3 => '创建中',
];
return $map[$value];
}
public function shop()
{
return $this->hasOne(Shop::class, 'id', 'shop_id');
}
}