// +---------------------------------------------------------------------- declare (strict_types = 1); namespace app\common\model; /** * 短信提醒模板 * Class Delivery * @package app\common\model */ class SmsRemind extends BaseModel { const FTYPE = [1=>'已下单待发货']; // 定义表名 protected $name = 'sms_remind'; protected $append = ['ftype_text','hours_text']; public function getFtypeTextAttr(){ return SELF::FTYPE[$this->ftype]??''; } public function getHoursTextAttr(){ $arr = explode(',', $this->hours); $newarr = []; foreach($arr as $r){ $newarr[] = $r.":00"; } return implode(",",$newarr); } // 定义主键 protected $pk = 'id'; //添加记录历史 public function add($data){ $his = [ "create_time"=>time(), "update_time"=>time() ]; $his = array_merge($his,$data); SmsRemind::create($his); return true; } public function getList(array $param = []){ // 查询列表数据 return $this->with([])->paginate(15); } /** * 更新记录 * @param array $data * @return bool */ public function edit(array $data) { $this->transaction(function () use ($data) { // 更新记录 $this->save($data); }); return true; } /** * 获取记录 * @param int $id * @param array $with * @return static */ public static function detail(int $id, array $with = []) { return static::get($id, $with); } }